Jump to content

Selecting 2 fields from MYSQl and displaying them in PHP


$username

Recommended Posts

Hello Guys and Gals,

 

    Can this be done with this code.

I want both fname and lname to be displayed in the drop down box.

 

	<?
			  $sql = "SELECT fname, lname FROM admin ORDER BY `ID` DESC";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_assoc($result)) {
        echo "<option value=\"{$row['fname, lname']}\">{$row['fname, lname']}</option>";
      }
    }
  }
  ?>

	<?
			  $sql = "SELECT fname, lname FROM admin ORDER BY `ID` DESC";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_assoc($result)) {
        echo "<option value=\"$row[fname], $row[lname]}\">$row[fname], $row[lname]</option>";
      }
    }
  }
  ?>

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.