filtering SQL table results
Posted: Wed Nov 26, 2008 9:51 pm
I am trying to filter results from a SQL table where if the result is one thing, it prints in black and if it's another, it prints in red. I can't figure out why this is not working because I saw the same setup of code on someone's website when they were trying to explain how to do it.. My problem is that it prints the results but all in red. When I was testing it, the SQL table said a couple of them should have printed out black.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
extract($row);
if ($row['variable'] == '1') {
echo '<font face="Arial" size="2" color="#000000">';
echo '<i> ' . $row['username'] . ' </i></font>';
echo '<br><br>';
}
else if ($row['variable'] == '') {
echo '<font face="Arial" size="2" color="#FF0000">';
echo '<i> ' . $row['username'] . ' </i></font>';
echo '<br><br>';
}
else {
}
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
extract($row);
if ($row['variable'] == '1') {
echo '<font face="Arial" size="2" color="#000000">';
echo '<i> ' . $row['username'] . ' </i></font>';
echo '<br><br>';
}
else if ($row['variable'] == '') {
echo '<font face="Arial" size="2" color="#FF0000">';
echo '<i> ' . $row['username'] . ' </i></font>';
echo '<br><br>';
}
else {
}
}