Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with syntax for MS Access query (newbie) 1

Status
Not open for further replies.

elantrip

Programmer
Joined
Dec 8, 2003
Messages
10
Location
US
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.
 
That works. Thank you so much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top