Jump to content

list populated with MySQL field data


Raf1k1

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);

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.