Jump to content

Recommended Posts

I'm having problems trying to populate a list with data from a MySQL DB.

 

So far what I have is this but it's giving me a blank page.

<label>Game Title:<span class="typo-1"></span></label>
<select  class="drop" name="" >
<?php
// Load in navigation links from the MySQL database
$sql = "SELECT game_title FROM xgame";
$result = $conn->query($sql) or die(mysqli_error());
if($result){
while($row = $result->fetch_object()){
echo "<option value="{$row->game_title}">{$row->game_title}</option>";                        
}
}
?>
</select>

Link to comment
https://forums.phpfreaks.com/topic/192650-list-populated-with-mysql-field-data/
Share on other sites

it looks like you've got double quotes in your double quotes

echo "<option value="{$row->game_title}">{$row->game_title}</option>";   

should probably be more like this

echo "<option value='{$row->game_title}'>{$row->game_title}</option>";   

blank page can mean that you're getting a fatal error but display_errors is turned off you can put this at the top of your script while you're developing so you can see the errors

ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.