sql returns?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hward
Forum Contributor
Posts: 107
Joined: Mon Apr 19, 2004 6:19 pm

sql returns?

Post by hward »

I have a form that posts a number "$items" to my script that tells the script how many items to pull from the database and then displays however many times by just echoing the display_block. it works fine that way but is there anyway to give give each return its own variable name. Instead of doing the display_block?


Code: Select all

<?php
$sql = "SELECT * 
  FROM $table_name 
	 WHERE av = '0'
	 ORDER BY Rand() LIMIT 0 ,$items 
	";
$result = @mysql_query($sql,$connection)
	or die("Couldn't execute query.");
 
while ($row = mysql_fetch_array($result)) {
	$item = $row['item'];
	$pic = $row['pic'];

 $display_block .= "<img border='0' src='pics/$pic' width='150' height='233'>";
}
?>
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Put them in an array.
Post Reply