Well, here is the code that correctly lists the categories and the checkboxes:
Code:
$sql = "SELECT cat_id, category FROM category ORDER BY category";
$result_cat = mysql_query($sql,$connection) or die("Couldn't execute $sql query. <br> mysql error: ".mysql_error());
$count=0;
while ($row = mysql_fetch_array($result_cat))
{
$count++;
echo '<td width="253"><input type="checkbox" name="cats[]" value="'.$row['cat_id'].'">' .$row['category'].'</td>';
if (($count % 3) == 0){
echo "</tr>";
}
}
To get the categories for a particular event_id I tried this but it didn't work:
Code:
$sql = "SELECT * FROM eventcat WHERE event_id = '".$_GET['event_id']."' ";
$result_evcat = mysql_query($sql,$connection) or die("Couldn't execute $sql query. <br> mysql error: ".mysql_error());
while($row = mysql_fetch_array($result_evcat))
{ $count++;
$evcat_id = $row['cat_id'];
}
with this in the output line:
Code:
<td width="253"><input type="checkbox" name="cats[]" value="<?php echo $row['cat_id'];?>"<?php if($row['cat_id'] == $evcat_id){echo " checked";}?>> <?php echo $row['category'];?></td>';
Bookmarks