justinjkiss Posted March 14, 2012 Share Posted March 14, 2012 OK below is my code. the values for $row['state'] are in this format "AL - Alabama" its got the space in it. while($row = mysql_fetch_array($result)) { echo "<option value=" . $row['state'] . '">' . $row['state']; } ?> When i run the script it outputs HTML as this <option value="AL" -="" alabama"="">AL - Alabama</option> As you can see at the space it terminates and puts the " in. Im assuming this is a rookie programming mistake. Please help, Justin Quote Link to comment https://forums.phpfreaks.com/topic/258945-easy-fix-im-assuming/ Share on other sites More sharing options...
smerny Posted March 14, 2012 Share Posted March 14, 2012 you don't have an opening quote for the value... actually your quotes are more messed up after that as well try this echo "<option value='" . $row['state'] . "'>" . $row['state'] ."</option>"; Quote Link to comment https://forums.phpfreaks.com/topic/258945-easy-fix-im-assuming/#findComment-1327463 Share on other sites More sharing options...
justinjkiss Posted March 14, 2012 Author Share Posted March 14, 2012 Thanks a ton... i feel stupid for that miss Quote Link to comment https://forums.phpfreaks.com/topic/258945-easy-fix-im-assuming/#findComment-1327466 Share on other sites More sharing options...
AyKay47 Posted March 14, 2012 Share Posted March 14, 2012 Something that I like to do is wrap array indices in curly braces when using double quotes. echo "<option value=\"{$row['state']}\">{$row['state']}</option>"; I'm too lazy to concatenate all of the time, improves readability though. Quote Link to comment https://forums.phpfreaks.com/topic/258945-easy-fix-im-assuming/#findComment-1327467 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.