farahZ Posted May 15, 2013 Share Posted May 15, 2013 i have a table in mysql/phpmyadmin Food, Size, Calories i concatenated 2 values and its working successfully in the drop down list according to this code: <?PHP $query = "SELECT Food,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['Calories']."</option>"); } ?> i need to show the Size too!!and this code isnt working any help?? while($row = mysqli_fetch_assoc($result)) { echo ("<option VALUE=\"".$row['Food']."\" " . ($food == $row['Food'] ? " selected" : "") . ">".$row['Food'].' - ' .$row['Size']. ' - '.$row['Calories']."</option>"); } Quote Link to comment Share on other sites More sharing options...
Solution taquitosensei Posted May 15, 2013 Solution Share Posted May 15, 2013 It looks like you're not selecting the size. SELECT Food,Calories FROM food order by Food i have a table in mysql/phpmyadmin Food, Size, Calories i concatenated 2 values and its working successfully in the drop down list according to this code: <?PHP $query = "SELECT Food,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['Calories']."</option>"); } ?> i need to show the Size too!!and this code isnt working any help?? while($row = mysqli_fetch_assoc($result)) { echo ("<option VALUE=\"".$row['Food']."\" " . ($food == $row['Food'] ? " selected" : "") . ">".$row['Food'].' - ' .$row['Size']. ' - '.$row['Calories']."</option>"); } Quote Link to comment Share on other sites More sharing options...
farahZ Posted May 15, 2013 Author Share Posted May 15, 2013 thanks .. !!i forget to add it in the query Quote Link to comment Share on other sites More sharing options...
buzzycoder Posted May 15, 2013 Share Posted May 15, 2013 Better create variables like below: <?php $food = $row['Food']; $size = $row['Size']; $calories = $row['Calories']; ?> And use it easily by just placing variable names. Hope it helps you! Quote Link to comment 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.