kramerkeller Posted January 31, 2007 Share Posted January 31, 2007 My HTML intention is this <option value="username"> firstname lastname </option> Pretty simple - except I am inputting username, firstname, lastname from a database HELP - here is the code belowe $result = get_users(); $num_results = $result->num_rows; echo"<select name='salesperson'>"; for ($count = 0; $count<$num_results; $count++) { $row = $result->fetch_assoc(); echo "<option value='".$row['username']."'>".$row['firstname']." ".$row['lastname']."</option>"; } ?> Link to comment https://forums.phpfreaks.com/topic/36533-help-with-escape-characters-i-believe/ Share on other sites More sharing options...
Psycho Posted January 31, 2007 Share Posted January 31, 2007 I don't see any problem with that code. What problems are you experiencing? It could be a little more efficient. Are you just wanting to have double quotes instead of single quotes int he output? If so, try this: <?php $result = get_users(); echo"<select name='salesperson'>"; while ($row = $result->fetch_assoc()) { { echo "<option value=\"{$row['username']}\">{$row['firstname']} {$row['lastname']}</option>"; } ?> Link to comment https://forums.phpfreaks.com/topic/36533-help-with-escape-characters-i-believe/#findComment-173967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.