Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>Searching for item...</title>
- </head>
- <body bgcolor=#ffffff>
- <?php
- $username = "admin";
- $password = "admin";
- $hostname = "localhost";
- $port = "50000";
- $database="HLDB";
- $conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"."HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$username;PWD=$password";
- $conn = odbc_connect($conn_string, '', '');
- echo "<h2>Search Results:</h2><p>";
- //Retrieve input from find field on previous page and store in a variable
- $find = $_POST['find'];
- echo "User searched for: " . $find . "<br><br>";
- //If they did not enter a search term we give them an error
- if ($find == "")
- {
- echo "<p>Please scan for an item!";
- exit;
- }
- // Otherwise we connect to our Database
- if ($conn){
- echo "Connection succeeded. n";
- odbc_close($conn);
- }
- else{
- echo "Connection failed. n";
- }
- //Now we search for our search term, in the field the user specified
- $sql = "SELECT * FROM NULLID.ITEMS WHERE 'ITEM NO.' LIKE '%$find%'";
- $rs=odbc_exec($conn,$sql);
- //fetch tha data from the database
- while(odbc_fetch_row($rs))
- {
- //display the data
- echo odbc_result($rs, "Description 1"), "n";
- }
- //This counts the number or results - and if there wasn't any it gives them a little message explaining that
- $anymatches=odbc_num_rows($sql);
- if ($anymatches == 0)
- {
- echo "Sorry, but we are unable to find this product...<br><br>";
- }
- //And we remind them what they searched for
- echo "<b>Searched For:</b> " .$find;
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement