Hi Guys,
Is it possible to insert an "if" statement inside a "while" loop?
Here's the code i have at the moment.
$sql = "SELECT * from callbacks";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$idno = $row['id'];
$name = $row['name'];
$number = $row['number'];
$service = $row['service'];
$timecall = $row['calltime'];
$reason = $row['reason'];
$status = $row['status'];
if ($status == ""){
$tdcolor = "#FFFFFF";
$fontcol = "#FF0000";
}else{
$tdcolor = "#FF0000";
$fontcol = "#FFFFFF";
echo ' <tr>
<td height="40" bgcolor="'.$tdcolor.'"><div align="center">'.$name.'</div></td>
<td bgcolor="'.$tdcolor.'"><div align="center"><font color="'.$fontcol.'">'.$number.'</div></td>
<td bgcolor="'.$tdcolor.'"><div align="center"><font color="'.$fontcol.'">'.$service.'</div></td>
<td bgcolor="'.$tdcolor.'"><div align="center"><font color="'.$fontcol.'">'.$timecall.'</div></td>
<td valign="middle" bgcolor="'.$tdcolor.'"><font color="'.$fontcol.'">
<div align="center">
<form id="form1" name="form1" method="GET" action="process.php" enctype="application/x-www-form-urlencoded"><input name="id" type="hidden" value="'.$idno.'"/>
<input name="called" type="submit" id="called" value="Called" />
<input name="Notcalled" type="submit" id="Notcalled" value="Not Called" />
</form>
</div></font></td>
<td bgcolor="'.$tdcolor.'"><div align="center"><font color="'.$fontcol.'">'.$reason.'</font></div></td>
</tr>';
}}
}
I understand why it's not working. Due to the use of a }, which the while loop is using. But any ideas on how i could get it working?
Thanks a bunch 🙂
Dave