<?php
$con= mysql_connect("localhost","sharad","gupta");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Employees", $con);
$qry= "SELECT id,invoice_number,CASE id
WHEN 1 THEN 'Net due in 5 days'
WHEN 2 THEN 'Net due in 10 days'
WHEN 3 THEN 'Net due in 30 days'
WHEN 5 THEN 'Net due in 50 days'
ELSE 'Illegal'
END AS 'Status'
from invoices";
$result=mysql_query($qry)or die(mysql_error());
echo"<tableborder='1'>
<tr>
<th>ID</th>
<th>InvoiceNumber</th>
<th>Status</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['invoice_number'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?> |