will35010 Posted June 1, 2009 Share Posted June 1, 2009 I'm using this code to populate a select box. I want the names to show up as last name, first name and the dl field hidden. I want to use dl as the value since it will always be unique. Thanks. function getDrivers() { $sql = "SELECT fname, lname, dl FROM drivers"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['fname']."\">".$row['lname']."\n "; } Link to comment https://forums.phpfreaks.com/topic/160549-solved-phphtml-help/ Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 <?php function getDrivers() { $sql = "SELECT fname, lname, dl FROM drivers"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"$row['dl']\">".$row['lname'].",".$row['fname']."</option>"; } Link to comment https://forums.phpfreaks.com/topic/160549-solved-phphtml-help/#findComment-847317 Share on other sites More sharing options...
Alex Posted June 1, 2009 Share Posted June 1, 2009 Well, if it's a function you want it to return, rather than echo.. right? function getDrivers() { $sql = "SELECT fname, lname, dl FROM drivers"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { $list .= '<option value="' . $row['dl'] . '">' . $row['lname'] . ', ' . $row['fname'] . '</option>'; } return $list; } Link to comment https://forums.phpfreaks.com/topic/160549-solved-phphtml-help/#findComment-847320 Share on other sites More sharing options...
will35010 Posted June 1, 2009 Author Share Posted June 1, 2009 Thanks!!! Link to comment https://forums.phpfreaks.com/topic/160549-solved-phphtml-help/#findComment-847323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.