whare Posted August 20, 2006 Share Posted August 20, 2006 Hi Allright i have been trying to work with dropdown boxes sending the info to a database but the info in the dropdown is also be pulled from the db so when i submit the form it put the php code into the db but not the option so something like this[code]<select size="1" name="D1"> <? $result = mysql_query("SELECT * FROM pilot ORDER BY pilotid ASC") or die(mysql_error()); ?><option value="$row['dbcolum']"><? echo $row['dbcolum']; ?></option> </select>[/code]now that would place into my db $row['dbcolum']; and not the text that it should put in Any ideas?Thanx Link to comment https://forums.phpfreaks.com/topic/18066-problem/ Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 Try this:[code]$result = mysql_query("SELECT * FROM pilot ORDER BY pilotid ASC") or die(mysql_error());echo '<select size="1" name="D1">';while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<option value="' . $row['dbcolum'] . '">' . $row['dbcolum'] . '</option>';}echo '</select>';[/code] Link to comment https://forums.phpfreaks.com/topic/18066-problem/#findComment-77437 Share on other sites More sharing options...
whare Posted August 20, 2006 Author Share Posted August 20, 2006 Thanx I will give that a go :) Link to comment https://forums.phpfreaks.com/topic/18066-problem/#findComment-77439 Share on other sites More sharing options...
desithugg Posted August 20, 2006 Share Posted August 20, 2006 yea he needed echo Link to comment https://forums.phpfreaks.com/topic/18066-problem/#findComment-77441 Share on other sites More sharing options...
inqztve Posted August 20, 2006 Share Posted August 20, 2006 $result = mysql_query("SELECT * FROM pilot ORDER BY pilotid ASC")$rows = mysql_numrows($result);$choice = "";$count = 0;while($count < $rows) { $choice = $choice . "<option value=". mysql_result($result, $count, "your_column"). ">". mysql_result($result, $count, "your_column"). "</option>"; $count++; }<select size="1" name="D1"><?echo $choice; ?></select>>> Please check for typos :). Link to comment https://forums.phpfreaks.com/topic/18066-problem/#findComment-77444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.