Page 1 of 1

How to echo all fields/rows from a MYSQL Table?

Posted: Mon Feb 06, 2006 7:20 am
by kaisellgren
Hello!

I need to make a listbox including all fields/rows/whatever in a table. The code I have so far:

Code: Select all

<?php

foreach ( as $item)
 {
  echo '<option value="'.$item.'">'.$item.'</option>';
 }
?>
Can someone quickly "fill" my code?

Posted: Mon Feb 06, 2006 11:41 am
by Burrito
if you want the field names, use something like 'desc %tablename%' for your query.

if you want the values, then just use a standard select.

you'll then need to loop over your query using a while loop (not a foreach) and display the results within your loop.