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 Quote Link to comment 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] Quote Link to comment 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 :) Quote Link to comment Share on other sites More sharing options...
desithugg Posted August 20, 2006 Share Posted August 20, 2006 yea he needed echo Quote Link to comment 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 :). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.