Page 1 of 1

Displaying images

Posted: Wed Jun 07, 2006 2:15 am
by leewad
Hi

I`m trying to pull from a database a list of images for a reference number, i.e.

reference acbd has 6 images stored

image1
image2
image3
image4
etc

how can i pull these from the database and use them?

I have created this to pull them:

Code: Select all

$result1=MYSQL_QUERY( "SELECT * FROM $table WHERE reference  ='$ID' ");

if(mysql_num_rows($result1)) {

   while($row = mysql_fetch_row($result1))
  {

    $picture[$i] = $row["1"];


  $i++;


  } }

$image1 = $picture[1];
$image2= $picture[2];
etc

but its not working, any ideas to where i`m going wrong?

Posted: Wed Jun 07, 2006 9:33 am
by Bill H
Not knowing your database structure or anything...
Two things leap out at me:

Code: Select all

$result1=MYSQL_QUERY( "SELECT * FROM $table WHERE reference  ='$ID' ");
The function isn't going to be recognized in capitals, and the spaces in the query string might or might not be problematic.
Try:

Code: Select all

$result1=mysql_query( "SELECT * FROM $table WHERE reference='$ID'");
The other:

Code: Select all

$image1 = $picture[1];
$image2= $picture[2];
Arrays in PHP start at zero. The $picture indices should be 0 and 1.

These suggestions may or may not solve the problem, but they are a start. If they don't then if you'll provide more about the structure of your database we'll give it another shot.