Jump to content

[SOLVED] list box


techker

Recommended Posts

hey guys i have this list box that selects from a database.

 

as is it only selects the first name.i need it to select both first and last name?

 

$link = mysql_connect("localhost", "techker_techker", "techker");
mysql_select_db("techker_trainerstool");
  
$query = "SELECT client_first FROM trainers_clients";
$result = mysql_query($query);

print "<SELECT name=client>";
while ($line = mysql_fetch_array($result))

{
foreach ($line as $value)

{

print "<OPTION value='$value'";
}
print ">$value</OPTION>";
}


mysql_close($link);
print "</SELECT>";

 

i have tryed:

 

adding another query for last name.but showed first name on one line then last on another line..

 

select client_fisrt,client_last from...(did not work,only showed the first name)

 

select (client_fisrt,', ',client_last) no success same as the other

 

i have tryed lots more combos but no succes or error messages?

 

is there a way to do it?

Link to comment
https://forums.phpfreaks.com/topic/138194-solved-list-box/
Share on other sites

$link = mysql_connect("localhost", "techker_techker", "techker");

mysql_select_db("techker_trainerstool");

 

$query = "SELECT id,client_first,client_last FROM trainers_clients";

$result = mysql_query($query)or die(mysql_error());

 

print "<SELECT name=\"client\">";

while ($line = mysql_fetch_array($result)) {

echo "<option value=\"$line[id]\">$line[client_first] $line[client_last]</option>";

 

}

print  "</select>";

 

 

id is not needed if you are just trying to pull that info.

try that

Link to comment
https://forums.phpfreaks.com/topic/138194-solved-list-box/#findComment-722490
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.