jc_gmk
07-31-2007, 11:29 AM
Hopefully this is a simple problem:
I have a while statement in my php code that prints out the rows from a mysql database. This works fine.
while($info = mysql_fetch_array( $result ))
{
print "<div>" . $info['tablerow'] . "</div>";
}
My question is: can I use an IF statement within the while statement that doesn't effect all of the results. e.g.
while($info = mysql_fetch_array( $result ))
{
if ($info['anothertablerow'] == true)
{
print "This text is printed only for rows with a value";
}
else
{
print " ";
}
print "<div>" . $info['tablerow'] . "</div>";
}
I have a while statement in my php code that prints out the rows from a mysql database. This works fine.
while($info = mysql_fetch_array( $result ))
{
print "<div>" . $info['tablerow'] . "</div>";
}
My question is: can I use an IF statement within the while statement that doesn't effect all of the results. e.g.
while($info = mysql_fetch_array( $result ))
{
if ($info['anothertablerow'] == true)
{
print "This text is printed only for rows with a value";
}
else
{
print " ";
}
print "<div>" . $info['tablerow'] . "</div>";
}