retieving table data from mysql database & display on web

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
helpASAP
Forum Newbie
Posts: 1
Joined: Fri Apr 04, 2008 10:26 am

retieving table data from mysql database & display on web

Post 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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

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

Post 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'] . '" />
 
Post Reply