farahZ Posted May 29, 2013 Share Posted May 29, 2013 hey guys!!!i was working on extractinng value from MySql and inserting them in a drop-down list but suddenly i realized i had duplicates in the list!! but no duplicates in the table when i open mysqlthats the whole code please help ( <select name="foodType" onChange="autoSubmit();"> <option VALUE=""></option> <?PHP $query = "SELECT Food, Size, Calories FROM food order by Food"; $result = mysqli_query($con,$query); while($row = mysqli_fetch_assoc($result)) { echo ("<option VALUE=\"".$row['Food']."\" " . ($food == $row['Food'] ? " selected" : "") . ">".$row['Food'].' - ' .$row['Size']. ' - '.$row['Calories']."</option>"); } ?> Link to comment https://forums.phpfreaks.com/topic/278541-duplicates-in-the-dropdown-list/ Share on other sites More sharing options...
farahZ Posted May 29, 2013 Author Share Posted May 29, 2013 the table in mysql has: FID---Food---Size---Calories in the dropdown list.. each option has: Food--Size--Calories Link to comment https://forums.phpfreaks.com/topic/278541-duplicates-in-the-dropdown-list/#findComment-1432907 Share on other sites More sharing options...
kicken Posted May 29, 2013 Share Posted May 29, 2013 There is nothing in the code you posted that would cause duplicates in the select box, so if you are seeing them, then you have duplicates in your table, or there is some other code causing them that you have not shown. Link to comment https://forums.phpfreaks.com/topic/278541-duplicates-in-the-dropdown-list/#findComment-1432908 Share on other sites More sharing options...
farahZ Posted May 29, 2013 Author Share Posted May 29, 2013 ya i foundthanks for your help!!! Link to comment https://forums.phpfreaks.com/topic/278541-duplicates-in-the-dropdown-list/#findComment-1432909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.