Forum Moderators: coopster
Im writing a banner list script...user taps in what type of image they're looking for, and the script returns a list. I can do everything I need to do except one thing: categorize the results... What I want to produce is something like this:
Site----Name & Link---
heading: Site Name #1
Site1---banner1----
Site1---banner2----
heading: Site Name #2
Site2---banner3----
Site2---banner4----
Basically, I want to run my for statement, and say something like
if($Name[this_array_reference]!= $Name[this_previous_array] )
{ echo "Heading: Site[this_array_reference]";
The cut down version of what Im running is this:
echo "<table><tr>";
for($i = 0;$row = mysql_fetch_array($result);$i++)
{
echo "<td>".$row['Name_TE']."</td>\n";
echo "<td>".$row['img_name']."</td>\n";
}
echo "</tr></table>";
I just cannot seem to get the right code to check the current iteration value of name against the previous iteration value of name.
Thanks ;)
Phatzo
echo "<table><tr>";
$previous = false; // initialize
while [php.net] ($row = mysql_fetch_array($result)) {
if ($row['site'] !== $previous) {
echo "Heading: {$row['site']}";
$previous = $row['site'];
}
echo "<td>".$row['Name_TE']."</td>\n";
echo "<td>".$row['img_name']."</td>\n";
}
echo "</tr></table>";