I have a simple MS Access table that has three fields:
ID, ProducerName and Producer#
I need to query the table for a Producer# based on what the end user enters. Here is the initial HTML code that gets the ProdNum:
<HTML>
<HEAD>
<TITLE>Log In</TITLE>
</HEAD>
<BODY>
<FORM ACTION="getprod.php" METHOD="post">
Enter Producer Code:
<input name="ProdNum" type="text">
<BR>
</FORM>
</BODY>
</HTML>
Here is the getprod.php code:
<?php
$ProdNum = $_REQUEST['ProdNum'] ;
$db = odbc_connect("lsr","administrator","admin");
$ProdNum = trim($ProdNum);
/*$sql = "SELECT * from producer where Producer# = #$ProdNum#"; */
/*$sql="SELECT * FROM producer WHERE Producer# = [" . $ProdNum. "]";*/
$sql = "SELECT * from producer";
$result = odbc_exec($db, $sql);
while (odbc_fetch_into($result, &$row)) {
echo "$row[0] $row[1] $row[2]\n";
}
odbc_close($Connection);
?>
(I've left the comments to show the different syntax that I've used). The connection to the DB is ok. I do get results when the query is just "select * from producer". I don't get any results when I add the "where".
Any help would be greatly appreciated.
ID, ProducerName and Producer#
I need to query the table for a Producer# based on what the end user enters. Here is the initial HTML code that gets the ProdNum:
<HTML>
<HEAD>
<TITLE>Log In</TITLE>
</HEAD>
<BODY>
<FORM ACTION="getprod.php" METHOD="post">
Enter Producer Code:
<input name="ProdNum" type="text">
<BR>
</FORM>
</BODY>
</HTML>
Here is the getprod.php code:
<?php
$ProdNum = $_REQUEST['ProdNum'] ;
$db = odbc_connect("lsr","administrator","admin");
$ProdNum = trim($ProdNum);
/*$sql = "SELECT * from producer where Producer# = #$ProdNum#"; */
/*$sql="SELECT * FROM producer WHERE Producer# = [" . $ProdNum. "]";*/
$sql = "SELECT * from producer";
$result = odbc_exec($db, $sql);
while (odbc_fetch_into($result, &$row)) {
echo "$row[0] $row[1] $row[2]\n";
}
odbc_close($Connection);
?>
(I've left the comments to show the different syntax that I've used). The connection to the DB is ok. I do get results when the query is just "select * from producer". I don't get any results when I add the "where".
Any help would be greatly appreciated.