techker Posted December 23, 2008 Share Posted December 23, 2008 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 More sharing options...
krv Posted December 23, 2008 Share Posted December 23, 2008 $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 More sharing options...
techker Posted December 23, 2008 Author Share Posted December 23, 2008 perfect!thx dude!! i guess this was the key: "<option value=\"$line[id]\">$line[client_first] $line[client_last]</ Link to comment https://forums.phpfreaks.com/topic/138194-solved-list-box/#findComment-722494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.