I am using $row = mysql_fetch_assoc($result) to grab data from my database, and then display all my data with a loop. The problem is that with a loop all the display looks the same. But I want some of my results to look different.
For example, I want the name of the 1st row to be in bold, I want the 5th result to have a bigger picture, etc
In such cases, what i would do is have a (or more) flag fields which are to be bold since making a record bold means that should have something different meaning (like is special product=Y then make the product bold or different color in case of ecommerce app.). So that you can have easily done such anything in the loop.
while($rows = mysql_fetch_assoc($result)){
if($rows['is_bold'] == 'Y'){
// make the record bold
}
if($rows['is_special'] == 'Y'){
// then make something different
}
}
rajug, the products don’t have anything different, they are in order of newest to oldest, and I want to have some products to stand out, based on when they were added to the system.
galen, your code seems to be what I’m looking for, but I can’t get it to work, this is what I have:
[COLOR=#000000][COLOR=#007700]<?php
while ([/COLOR]$row = mysql_fetch_assocCOLOR=#007700) {
[/COLOR][/COLOR]++$row_num
[COLOR=#000000]//this is how the result should look for all products
echo $row[‘title’];
echo $row[‘description’];
echo " <img border=‘0’ src='images" . $row[‘picture’]; . ".jpg’> "[COLOR=#007700];
[/COLOR][/COLOR] //this is how the result should look for 1st product[COLOR=#000000] echo $row_num == 1 ? ‘<strong>’.$row[‘title’].‘</strong>’ : $row[‘title’]; echo “FIRST ONE”;
echo $row[‘description’];
echo " <img border=‘8’ src='images" . $row[‘picture’]; . ".jpg’> "[COLOR=#007700];
[/COLOR][/COLOR]//this is how the result should look for 5th product echo $row_num == 5 ? ‘<b>’.$row[‘title’].‘</>’ : $row[‘title’]; echo “FIVE”;
echo $row[‘description’];
echo " <img border=‘8’ src='images" . $row[‘picture’]; . ".jpg’> ";