help with query

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
cybershot
Forum Commoner
Posts: 29
Joined: Thu Jul 24, 2008 12:06 pm

help with query

Post by cybershot »

I made a table, inserted values from the form, now I want to display that data. I tried echo "SELECT * FROM tblBills" ; but that just displays the query. How do I get it to actually display the table data?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: help with query

Post by social_experiment »

Try this :

Code: Select all

<?php
// your query
$query = "SELECT * FROM tblBills";
$sql = mysql_query($query);
while ($display_array = mysql_fetch_array($sql)) {
 // you use the field names of the table here
 echo $display_array['field1'];
 // etc
} ?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
cybershot
Forum Commoner
Posts: 29
Joined: Thu Jul 24, 2008 12:06 pm

Re: help with query

Post by cybershot »

Thank you. That did the trick.
Post Reply