WHILE

------=_NextPart_000_0001_01CA085F.4B9B6170
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello everyone=85



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 =3D $_GET['id_PROD'];

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

$result =3Dmysql_query($sql,$conn);



while($row_FOTOS=3Dmysql_fetch_row($result))

{

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

}

?>



Thanks



+ =
_
// Emiliano Boragina _
// Dise=F1o & Comunicaci=F3n //////////////////
+ =
_
// emiliano.boragina [at] gmail.com /
// 15 40 58 60 02 ///////////////////////////
+ =
_




------=_NextPart_000_0001_01CA085F.4B9B6170--
Emiliano Boragina [ So, 19 Juli 2009 15:54 ] [ ID #2009199 ]

Re: WHILE

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
Yves Sucaet [ So, 19 Juli 2009 17:13 ] [ ID #2009200 ]
PHP » gmane.comp.php.database » WHILE

Vorheriges Thema: Prepared Statement Insert Problem
Nächstes Thema: finder (I AM REALLY SORRY)