What I need to do for this one is retrieve results from a relational database and check to see which values are present, checking the ones that are but also showing the ones that are not in case an update/update/delete is required. Right now I would just like to work on pulling these results.
geography_zone (zone_id primary)
geography_area (area_id primary)
relation_geography (geography_id, zone_id, area_id)
I am pulling the results based on the zone_id.
This is how I have normally been retrieving results when they are stored in a comma dileminated field.
$result = mysql_query('SELECT * FROM geography_area') or exit(mysql_error());
while ($row = mysql_fetch_assoc($result)) {$area[$row['area_id']] = $row['area'];}
$result = mysql_query('SELECT area_id, zone_id FROM relation_geography WHERE zone_id = ' . $_GET['zone_id']) or exit(mysql_error());
$area_exp = explode(',', mysql_result($result, $area_id));
foreach ($area as $key => $value)
{
echo '<input type="checkbox" name="area_id[]" value="' . $key . '"';
if (in_array($value, $area_exp)) {
echo ' checked';}
echo '>' . $value . '';
}
As a side note and not very important at this moment, how would I go about making this section a bit more cleaner. There are a total of 855 areas which can be selected so as you can guess the input checkboxes are pretty messy in that format. Is there a way to break it over 3 or 4 colums?