How to display result?

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
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

How to display result?

Post by ianhull »

Hi I am using this sql to select records from the db but how would I display these records when they have been selected?

Code: Select all

<?php 
		include_once("connect.php"); ?>
$sql = 'SELECT * FROM `customers` LIMIT 0, 30 ';


<?php echo  $customers ?>
Does not work, what should I do now?

Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

include_once("connect.php");
$result = mysql_query('SELECT * FROM `customers` LIMIT 0, 30 ')or die(mysql_error());  

while ($row = mysql_fetch_assoc($result)) {
   echo $row['customers'];
}
Should read up on

mysql_connect()
mysql_query()
mysql_error()
mysql_fetch_assoc() or mysql_fetch_array()
Last edited by John Cartwright on Thu Jun 23, 2005 10:41 am, edited 2 times in total.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Post Reply