I will need some assistance from our php gurus.
My script makes a simple select statement from a database and displays the contents in a 4 Column table. So far its working as intended.
Problem:
I want the Cell holding the Zip Code ( or, if possible, the entire Row) to change its background color if the Zipcode = '00000';
I have tried various scenarios but i keep having parsing errors.- I am not sure if the position of my IF Condition is correct.
Any suggestions at a different approach will also be greatly appreciated.
Code:
<?php
// Try to connect to Oracle
if ($conn = OCILogon("hr", "hrw", "XE")) {
// Prepare the Query
$query = "SELECT city, State, Country, ZipCode from locations";
$stid = OCIParse($conn, $query);
// Fetch the Rows
if (OCIExecute($stid)) {
$numcols = OCINumCols($stid);
echo "<table width='80%', border='1', cellpadding='2', cellspacing='2'>";
echo '<tr>
<th bgcolor="#FF9966">CITY</th>
<th bgcolor="#FF9966">STATE Phone</th>
<th bgcolor="#FF9966">COUNTRY</th>
<th bgcolor="#FF9966">ZIP CODE</th>
<tr>';
while (OCIFetchInto($stid, &$result, OCI_ASSOC)) {
echo "<tr>
<td>";
echo $result['city'];
echo "</td>
<td>";
echo $result['State'];
echo "</td>
<td>";
echo $result['Country'];
echo "</td>
If ($result['ZipCode'] == 00000) {
<td bgcolor=\"#028021\">";
echo $result['ZipCode'];
echo "</td> }
else
{ echo $result['ZipCode'];}
</tr>\n";
}
echo "</tr></table>\n";
echo "<p>\n";
}
OCIFreeStatement($stid);
OCILogoff($conn);
} else {
$err = OCIError();
echo "Oracle Connect Error " . $err[text];
exit;
}
?>