Okay, here I go again pasting code to the guru's. For some reason, and I can't figure out why, this query won't display any results.
<html>
<head>
<title>Query by Company</title>
<?
if ($submit) {
?>
<META HTTP-EQUIV=Refresh CONTENT="86400">
<?
};
?>
</head>
<body bgcolor="#D5D5AB" text="#000000" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<div align="left">
<h2 align="left"><img src="/vad/Avnet_LSC.jpg" width="222" height="72"></h2>
<h2 align="left"><u><strong><font size="5">Database Query</font></strong></u>
</h2>
</div>
<?
if (!$submit) {
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST" name="query">
<table>
<tr>
<th align=right>Company:
<td><input name="company" type="text" size="10" maxlength="4">
<tr>
<td colspan=2 align=center>
<input type="submit" name="submit" value="Submit Query">
</table>
</form>
<?
}
else
{
$host = "172.16.30.45";
$user = "aaron";
$db = "vad";
$connection = pg_Connect("host=$host dbname=$db user=$user");
if (!$connection) {
die("Could not open connection to the database server");
}
$query = "SELECT * from shipper where company = '$company' order by invoice";
$result = pg_query($connection, $query) or die("Error in query:$query. " . pg_last_error($connection));
$rows = pg_num_rows($result);
if ($rows > 0)
{
?><table>
<table border=1>
<tr><th colspan=1><? echo $rows; ?> entries for <? echo $company; ?>
</td></th>
</table><?
for ($i=0; $i<$rows; $i++)
{
$row = pg_fetch_row($result);
?>
<table>
<table border=1>
<tr><th>Company</th><th>Invoice</th><th>Quantity</th><th>PC Charge</th><th>Month</th><th>Year</th><th>DB Serial Number</th></tr>
<tr><td><? echo $row[0]; ?></td><td><? echo $row[1]; ?></td><td><? echo $row[2]; ?></td><td><? echo $row[3]; ?></td><td><? echo $row[4]; ?></td><td><? echo $row[5]; ?></td><td><? echo $row[6]; ?></td></tr>
</table>
<?
}
}
else
{
?>
<font size="-1">No data available.</font>
<?
}
pg_close($connection);
}
?>
<p align="left"> </p>
<a href="index.htm">Return to Main Menu</a><br>
<p align="left"></p>
<a href="queryindex.htm">Return to Query Menu</a>
</body>
</html>
But when I have two inputs, it does. Like if I have a place for company and invoice in the form, and I change the query to $query = "SELECT * from shipper where company = '$company' and invoice = '$invoice' order by invoice"; it has absolutely no problems.
Any help is appreciated. Thanks!