weedpacket,
This is a photogallery for my website www.rupstar.com.
The current code is as follows:
<?php
$sql = "SELECT event_id FROM galleryTable";
$result = mysql_query( $sql, $link );
while ( $newArray = mysql_fetch_array($result) )
{
$event_id = $newArray['event_id'];
print "$event_id";
foreach ( 'event_id' as $val)
{
$sql1 = "SELECT * FROM galleryTable WHERE event_id = '$val' ORDER BY RAND() LIMIT 0,1";
$result1 = mysql_query( $sql1, $link );
while ( $newArray1 = mysql_fetch_array($result1) )
{
$title = $newArray1['title'];
$val = $newArray1['event_id'];
$fupload = $newArray1['fupload'];
include("event_name.php");
print "
<tr bgcolor=#666666>
<td width=21% align=right valign=top>
<a href=\"gallery.php?event_id=$val&title=$title&fupload=$fupload\"><img src=\"/images/$val/$fupload\"></a>
</td>
<td width=58% align=left valign=top>
<p class=subtitle> $event_name </p>
</td>
</tr>
<tr bgcolor=#666666>
<td colspan=2 align=right valign=top>
<hr noshade color=#CC3333>
</td>
</tr>
";
}
}
}
?>
The current error message is as follows:
ruplex
Warning: Invalid argument supplied for foreach() in /users/rupertbj/domains/rupstar.co.uk/html/photos1.php on line 28
ruplex
Warning: Invalid argument supplied for foreach() in /users/rupertbj/domains/rupstar.co.uk/html/photos1.php on line 28
bellasgarden
Warning: Invalid argument supplied for foreach() in /users/rupertbj/domains/rupstar.co.uk/html/photos1.php on line 28
Line 28 is the foreach line.
So, from the output I can see that when I print $event_id on the line before the foreach statement that the output is ruplex, ruplex, bellasgarden (each of these being a page of photos in the photogallery).
What I want to be able to do is loop through the output code until all three outputs (ruplex, ruplex and bellasgarden) have been processed - basically assigning each output to $val once each.
I also want to strip out duplicates (i.e. just have one ruplex, although there are several entries under this $event_id in the DB table).
I hope that makes sense!
Rupstar