Hello, I have a question about arrays. I have everything set up where a query gets the data from the db and places into an array which is displayed on my page. The problem is that the "array title" does not change with the page. Here is the piece of code that places the "array heading" on my page. <?php echo ' Worksheets for ',( isset($_GET['queryData']) ? htmlspecialchars($_GET['queryData']).' ' : 'Math' ),''; ?> Code (markup): So for example if I'm on page test.php?subject=math&category=counting I would want the heading to reflect "Worksheets for Math-Counting" or something to that effect. Right now it will say Worksheets for Math on every page(the subject and category variables do not display). I've tried removing the word math from the ' ' and putting a GET there. Don't work. Thanks in advance for any help.
echo out the "worksheets for" and then do a foreach It doesn't have to be in one statement. Don't be afraid of white space and making code readable. Any impact on speed will be more than overcome by the bandwidth and browser processing speeds.
$get = ''; foreach($_GET as $key => $value) { $temp = (string) trim(strip_tags($value)); if(!empty($temp)) $get .= htmlspecialchars($temp) . ' '; } printf("Worksheet for %s Math", $get); PHP:
If you don't know the basics of the syntax check out php.net, in this case you'd go to www.php.net/foreach Code (markup):