[PHP-DB] WHILE

2009-07-19 Thread Emiliano Boragina
Hello everyone…

 

First, I thank you all for the help on the past week.

I could do the finder... thank you very much.

 

Now... I must print images from the product. But the data about the product
is in a table and the pictures are in other table.

The picture table has 12 columns, the first two are ID and CODE, the rest of
them are picture1, picture2, picture3... picture10.

Can be not always the product has all ten pictures, can be three, one, etc.

I dont know how to use WHILE to print pictures without print ID and CODE
columns.

 

This my code:

 

?

$ID = $_GET['id_PROD'];

$sql = SELECT * FROM picture WHERE id = '$ID';

$result =mysql_query($sql,$conn);

 

while($row_FOTOS=mysql_fetch_row($result))

{

 echo img src='products/$row [3]' border='0' height='384' /;

}

?

 

Thanks

 

+  _
   // Emiliano Boragina _
   // Diseño  Comunicación //
+  _
   // emiliano.borag...@gmail.com  /
   // 15 40 58 60 02 ///
+  _

 



Re: [PHP-DB] WHILE

2009-07-19 Thread Yves Sucaet
Why don't you use mysql_fetch_assoc() instead? You can address your fields 
directly, as in:



while($row_FOTOS=mysql_fetch_assoc($result))
{
echo img src='products/.$row [picture1].' border='0' 
height='384' /;
echo img src='products/.$row [picture2].' border='0' 
height='384' /;

}

Alternatively, you can specify which fields you want in your SQL statement:

$sql = SELECT picture1, picture2 FROM picture WHERE id = '$ID';
$result =mysql_query($sql,$conn);
while($row_FOTOS=mysql_fetch_array($result))
{
echo img src='products/$row [0]' border='0' height='384' /; 
// picture1
echo img src='products/$row [1]' border='0' height='384' /; 
// picture2

}



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php