08-06-2008, 05:31 AM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Because it only has one result set to work with. If you need it to run the loop on that second query each time the first loop runs, you need to nest the query inside the first loop so that $nation_list will repopulate itself each time - alternatively, and better yet, as it only runs the query once, you could run the nested loop outside of the first loop and save the results to a variable, then just echo that variable inside the first loop each time. Ala;
PHP Code:
<?php $sql_nation = "SELECT * FROM national ORDER BY national_name ASC"; $nation_list = mysql_query($sql_nation) or die (mysql_error());
$nation_list = '';
while($row = mysql_fetch_assoc($nation_list)) { $nation_list .= '<option value="'.$row['n_id'].'">'.$row['national_name'].'</option>'."\n"; }
$sql = 'SELECT * FROM rank LEFT JOIN national on national.n_id = rank.rank_nation ORDER BY rank ASC'; $result = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_assoc($result)) { ?> <tr> <td><?php echo $row['rank']; ?></td> <td><input name="rank" type="text" value="<?php echo $row['rank']; ?>" size="20" maxsize="100" /></td> <td><select name="national_id"><option selected value="<?php echo $row['national_id']; ?>"><?php echo $row['national_name']; ?></option> <option>-------</option> <?php echo $nation_list; ?> </select></td> <td><input name="points" type="text" value="<?php echo $row['rank_points']; ?>" size="20" maxsize="100" /></td> </tr> <?php } ?>
-m
|
|
|
|