Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.