Jump to content

Simple problem with a multi-dimensional array of a mysql recordset


hmaloney

Recommended Posts

Hi,

I am sure this will take someone in the know about 5 seconds to fix!

 

I am putting the results of a recordset into a multidimensional array, but when I try and display the items in that array, I am only displaying the first one, and then the results are empty after that, no matter how many items are actually in the array.  I can't figure out why.

 

This is my code:

 

$strsql = "SELECT ProductID, Title, ImageURL FROM Products WHERE CategoryID = ".$myCatID." AND Available = 1";

$rs = mysql_query($strsql);

$arrProd[] = mysql_fetch_array($rs);  //** this must be where things are going awry

$z = mysql_num_rows($rs);  // I know that the value of $z is correct and matches the number of items that the query should return

 

$startingPoint = 0;

$endingPoint = 5;

if ($endingPoint > $z) {

  $endingPoint = $z;

}

for ($y = $startingPoint; $y < $endingPoint; $y++) {

  echo <img src='productimages/".($arrProd[$y]['ImageURL'])."'>";

  echo "<br />".($arrProd[$y]['Title']);

 

Thanks heaps for your help!!!

Heather

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.