Page 1 of 1

sql returns?

Posted: Tue Jul 06, 2004 12:21 am
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'>";
}
?>

Posted: Tue Jul 06, 2004 1:14 am
by kettle_drum
Put them in an array.