unidox Posted September 22, 2007 Share Posted September 22, 2007 My Code: if ($fieldtype[$i] == "selectb") { $r = mysql_fetch_array(mysql_query("SELECT * FROM `cp_divisions` ORDER BY division_id DESC")); $divis[] = $r['division']; echo "<select name=\"" . $field[$i] . "\">"; for ($o = 0; $o < count($r); $o++) { ?> <option value= "<?=$divis[$o]?>"> <?=$divis[$o]?> </option> </select> <? } } Works, but I have more than 1 in the table, how do I echo more than one? Link to comment https://forums.phpfreaks.com/topic/70241-select/ Share on other sites More sharing options...
unidox Posted September 22, 2007 Author Share Posted September 22, 2007 bump Link to comment https://forums.phpfreaks.com/topic/70241-select/#findComment-352848 Share on other sites More sharing options...
BlueSkyIS Posted September 22, 2007 Share Posted September 22, 2007 First, only use mysql_query once: $result = mysql_query("your sql here"). Then loop over the result, using mysql_fetch_array() each time, ala: while ($row = mysql_fetch_array($result)) { // Do something with $row here. } Link to comment https://forums.phpfreaks.com/topic/70241-select/#findComment-352854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.