Hi,
I have a form which has 10 dropdown lists on it, $hometeam1 - $hometeam10.
Thanks to a couple of guys on here I have been able to insert the info into the db fine, but my problem now is passing the info from the db to the dropdown lists when the record is edited, so that each dropdown shows the teamname that corresponds with the ID from the database, 😕 ?!
Here is the code I have been experimenting with;
global $db;
showheader();
$id = $_GET['id'];
$result = $db->sql_query("SELECT * FROM 4casts WHERE id='$id'",false,__FILE__,__LINE__);
$row = $db->sql_fetchrow($result);
$deadline = date('d-m-y', $row['deadline']);
// Build the drop down menus and store the generated code in an array
$teamlist = $db->sql_query("SELECT id,name FROM teams ORDER BY name");
$ddhome = array();
while (list($team_id, $team_name) = $db->sql_fetchrow($teamlist)) {
for ($i = 1; $i <=10; $i++) {
$home = $row['hometeam'.$i];
if(isset($home) && !empty($home))
{
$sel = ($home == $team_id) ? 'selected' : '';
} else {
$sel = ($home == $team_name) ? 'selected' : '';
}
}
$ddhome[] = '<option ' . $sel . ' value="' . $team_id . '">' . $team_name . '</option>';
}
//
... but because of my limited knowledge, cant seem to get it to work!
Thanks in advance for any help.