On this test page https://wintoweb.com/sandbox/question_2.php , the visitor can make searches in the DB and tick as many checkboxes as wished. When button [Accept...] is clicked, I want the result of all searches to be shown under 'Your selections so far'. Right now, only the last search is displayed. I tried using a global array to store the result of previous searches and increment it upon each new one. That's where I have a problem.
On top of file I have :
<?php
global $all_authors;
array ($all_authors, '');
?>
At bottom of file I have :
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
if(isset($_GET['search'])){
//echo 'Search</br>';
} elseif(isset($_GET['display_this'])) {
echo getNames();
}
function getNames() {
$rets = '';
if(isset($_GET['choices']) and !empty($_GET['choices'])){
foreach($_GET['choices'] as $selected){
$rets .= $selected.' -- ';
}
//array_push($all_authors, $rets); // This is the problem
//print_r($allAuthors); // this too
echo '</br><b>Your selections so far :</b></br>';
}
return $rets;
}
?>
EXPECTED: Results of all previous searches to be listed ACTUAL: No go due to problem with array_push(). See function gatNames()