Displaying Separate Checkbox Items
Posted: Fri Feb 12, 2010 1:29 pm
Hi guys,
I'm having a dilemma with Checkboxes, and displaying them in a basic HTML table.
I have a registration form, where participants can check off events they are participating in. The form then stores these events using serialize, into the MySQL database. When I view the field "events" in the db, there are 3 rows with the serialized events in them. This works fine. However, when I try to display the events, the only result I get is the first row of the "events" field. I tried to put it in a loop, but I butchered it majorly. I'm new to PHP, so this is probably a stupid question. Regardless, I've included the coding below, and a link to the display page. Any help would be appreciated, thanks!
Display page: http://zlot.polishalcons.org/test/groups/preps.php
I'm having a dilemma with Checkboxes, and displaying them in a basic HTML table.
I have a registration form, where participants can check off events they are participating in. The form then stores these events using serialize, into the MySQL database. When I view the field "events" in the db, there are 3 rows with the serialized events in them. This works fine. However, when I try to display the events, the only result I get is the first row of the "events" field. I tried to put it in a loop, but I butchered it majorly. I'm new to PHP, so this is probably a stupid question. Regardless, I've included the coding below, and a link to the display page. Any help would be appreciated, thanks!
Code: Select all
<td><font face="Arial, Helvetica, sans-serif"><?php
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$doQuery = mysql_query("SELECT events FROM preps");
$newnumb=mysql_num_rows($doQuery);
if($newnumb>0)
{
while($events=mysql_fetch_array($doQuery))
{
$events=unserialize($events['events']);
foreach($events as $list)
{
echo $list.'<br> ';
}
}
}
else
{
echo 'Undecided.';
}
mysql_close();
?></font></td>