Jump to content

[SOLVED] php/html help


will35010

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.