checkboxes and array
Posted: Tue May 15, 2007 6:53 am
feyd | Please use
As you can see the array is $selected_list and displays those boxes that have been checked. what i want to know is, how do i then use this array to retrieve data from a database?
The array is made up of database table names, named list 1, list 2 etc.
I need the query to take the result of the array, for example, list 2 and list 3 may be in the array, and the query will select the rows ONLY from the lists in the array.
I'm not sure If i eed to do this dynamically, which is why i'm not sure.
Thanks[/b]
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
I have a slight problem.
I have a form made up of checkboxes which is then stored in an array.Code: Select all
?php
if (!isset($_POST['list']))
{
echo "Please choose one of the following lists: <br><br>";
} else {
echo "You selected the following lists:<br>";
foreach ($_POST['list'] as $selected_list)
{
echo $selected_list."<br>";
}
}
?>
<form name="form1" method="post" action="results.php">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="checkbox" name="list[]" value="List 1"></td>
<td>List 1</td>
</tr>
<tr>
<td><input type="checkbox" name="list[]" value="List 2"></td>
<td>List 2</td>
</tr>
<tr>
<td><input type="checkbox" name="list[]" value="List 3"></td>
<td>List 3</td>
</tr>
<tr>
<td><input type="checkbox" name="list[]" value="List 4"></td>
<td>List 4 </td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>The array is made up of database table names, named list 1, list 2 etc.
I need the query to take the result of the array, for example, list 2 and list 3 may be in the array, and the query will select the rows ONLY from the lists in the array.
I'm not sure If i eed to do this dynamically, which is why i'm not sure.
Thanks[/b]
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]