Page 1 of 1

retieving table data from mysql database & display on web

Posted: Fri Apr 04, 2008 10:30 am
by helpASAP
right, i'm not the best at PHP I have to admit.

ok, I have a mySQL database and wish to get the data from one of my tables and display the data entries on one of my webpages. However, I want to display the data as checkboxes.
i'm guessing I do this with some sort of echo statement and a loop but I'm not sure, any one have any ideas?

I would be very grateful for any help.

:D

Re: retieving table data from mysql database & display on web

Posted: Fri Apr 04, 2008 1:43 pm
by aceconcepts
First you would query the database for the data and then display it:

Code: Select all

 
//QUERY THE DATABASE
$query=mysql_query("SELECT * FROM table");
 
//DISPLAY DATA
while($row=mysql_fetch_array($array))
{
   //DISPLAY THE CHECK BOX -  if you want the checkbox to be checked then use checked="checked" - this would usually be in a conditional statement
   echo'<input name="checkbox1" type="checkbox" value="' . $row['field_name'] . '" />