Hi guys, I think I need a help.
My teacher gave us a activity on Postgres and PHP to query what's inside the database file and code it to PHP to view the results.
I have a screenshot on the Database of the Postgre.
http://theoutdatedblogger.com/Email-Newsletters-Template/database.png
What I need to do is display the Referenceno column by Name
customerid, lastname, firstname, address, city, state, zip, referenceno
1007 GIANA TAMMY 9153 MAIN STREET AUSTIN TX 78710 1003
Instead I want it to display the 1003 reference number which is SMITH, LEILA based on the customerid. Screenshot provided above.
And this is my PHP code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Customer's Information</title>
<style type="text/css">
<!--
body,td,th {
color: #000000;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
body {
background-image: url(background.jpg);
background-color: #FFFFFF;
}
table {
border:solid #FF0000 2px;
}
-->
</style></head>
<body>
<div align="center">
<?php require_once('db_connection.inc.php'); ?>
<h3> Customer's Information </h3>
<hr />
<table border="2" bgcolor="#FFFFFF">
<tr>
<td><strong> Customer ID </strong></td>
<td><strong> Customer Name </strong></td>
<td><strong> Address </strong></td>
<td><strong> Referred Customer </strong></td>
</tr>
<?php
$query = pg_query("SELECT * FROM tblcustomer");// WHERE referenceno IN(1003, 1006, 1010)");
while($result = pg_fetch_array($query, NULL, PGSQL_ASSOC))
{
?>
<tr>
<td><?php echo $result[customerid]; ?></td>
<td><?php echo $result[lastname] . ", " . $result[firstname]; ?></td>
<td><?php echo $result[address] . ", " . $result[city] . ", " . $result[state] . ", " . $result[zip]; ?></td>
<td><?php if(empty($result[referenceno]))
echo " ";
else echo $result[referenceno]?></td>
<?php } ?>
</table>
<hr />
</div>
</body>
</html>
Here is also my database backup file: http://theoutdatedblogger.com/Email-Newsletters-Template/bookstore.backup
Any help will be great.