Newbie here. Please xcuse my igonrance.
I am attempting to modify a query SELECT statement based on checkboxes being checked or not in a seperate URL. The checkboxes (one for each field) will determine which fields will be shown in the query. Here is part of 'checkbox.php'.
<form name=checker method=post action="createquery.php">
<input type=checkbox name=pname checked> Player Name<br>
<input type=checkbox name=team checked> Team<br>
<input type=checkbox name=owner checked> Owner<br>
<p><input type=submit value=Update>
</form>
At 'createquery.php' I have a list of IF(ISSET())s for each checkbox and then create a variable to drop into my query called $batquery, like so.
if (isset($pname)) {$showplay="PlayerName";} else {$showplay="";}
if (isset($team)) {$showteam="Team";} else {$showteam="";}
if (isset($owner)) {$showowner="Owner";} else {$showowner="";}
$batquery="$showplay,$showteam,$showowner";
Now I want to return to ANOTHER .php file (call it query.php) and run my query using $batquery from createquery.php in the statement. My question is, how do I use this variable I've created in query.php? I've tried using an 'include' statement in query.php, and referencing 'createquery.php', but that always give me the two commas, with no values for $showplay, $showteam, or $showowner.
Is this an issue of declaring a variable globally?
if there's a better way to accomplish this I'm open to anything. Thanks for any help.