Hello,
I have 10 pictures, with 10 descriptions in my db.
This is a snippet of my code:
$query = "SELECT * FROM table";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$photo_url_1 = $row['photo_url_1'];
$photo_url_2 = $row['photo_url_2'];
$photo_url_3 = $row['photo_url_3'];
$photo_url_4 = $row['photo_url_4'];
$photo_url_5 = $row['photo_url_5'];
$photo_url_6 = $row['photo_url_6'];
$photo_url_7 = $row['photo_url_7'];
$photo_url_8 = $row['photo_url_8'];
$photo_url_9 = $row['photo_url_9'];
$photo_url_10 = $row['photo_url_10'];
$photo_desc_1 = $row['photo_desc_1'];
$photo_desc_2 = $row['photo_desc_2'];
$photo_desc_3 = $row['photo_desc_3'];
$photo_desc_4 = $row['photo_desc_4'];
$photo_desc_5 = $row['photo_desc_5'];
$photo_desc_6 = $row['photo_desc_6'];
$photo_desc_7 = $row['photo_desc_7'];
$photo_desc_8 = $row['photo_desc_8'];
$photo_desc_9 = $row['photo_desc_9'];
$photo_desc_10 = $row['photo_desc_10'];
}
I would like to use a while loop get all my $rows, like so:
$query = "SELECT * FROM table";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$i = 1;
while($i < 11)
{
$photo_url_$i = $row['photo_url_$i'];
$photo_desc_$i = $row['photo_desc_$i'];
}
}
Thanks for your help.