Jump to content

[SOLVED] PHP - Populate a Combo Box from SQL Query


grahamb314

Recommended Posts

PHP - Populate a Combo Box from SQL Query

 

Hi all,

 

I have a database with a series of fields. I wish those fields to all be displayed in a drop down box, row by row.

 

Does someone have some sample code to do this, or something better? - I can do this with a table that has 1 field, but not several!

 

Cheers,

Graham

Thanks for the link:

Ive modified what I Had and now have this:

But it doesnt display anything in the drop down box!?

 

<form action="delete_show_results.php" method="POST">

 

  <div align="center">

    <p>

      <select name="toDelete">

           

        <?php

require_once 'mysql_connect.php'; 

$allShows = mysqli_query($mysqli, "SELECT * FROM shows");

while ($row = mysqli_fetch_object($allShows)) { 

echo "<option value=\"<? echo $row->; ?>\"><? echo $row->Gallery; ?></option>";

}

?>

      </select>

    </p>

    <p>

      <input type="submit" value="Delete"></p>

     

  </div>

</form>

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.