All:
I need to display checkbox values on my edit page, but what I have now displays all checkboxes checked, instead of reading the checkbox values saved in my database table.
Here's the code.
I already have another query listing the checkbox items, if that helps.
Not certain if any of you need to see more to understand what I need help in. Let me know if you do.
Please help. Thank you.
I need to display checkbox values on my edit page, but what I have now displays all checkboxes checked, instead of reading the checkbox values saved in my database table.
Here's the code.
Code:
<div class="row">
<label>Event(s):</label>
<?php
while ($event = mysql_fetch_array($events)) {
$eventid = $event['id'];
$ename = htmlspecialchars($event['eventName']);
$result = @mysql_query(
"SELECT contact.id, contact.eventid, events.id, events.eventName
FROM `contact`, `events`
WHERE contact.eventid = events.id");
if (!$result) {
exit('<p>Error fetching event details: ' .
mysql_error() . '</p>');
}
if(mysql_num_rows($result)) {
echo "<span class='inline'><input type='checkbox' class='chkbx' checked='checked' name='eventid[]' value='$eventid' />$ename</span>";
} else {
echo "<span class='inline'><input type='checkbox' class='chkbx' name='eventid[]' value='$eventid' />$ename</span>";
}
}
?>
</div>
I already have another query listing the checkbox items, if that helps.
Code:
$events = @mysql_query('SELECT id, eventName FROM events');
if (!$events) {
exit('<p>Unable to obtain event list from the database.</p>');
}
Not certain if any of you need to see more to understand what I need help in. Let me know if you do.
Please help. Thank you.