I am having some trouble changing my script form running with mysql to running with access. Everything is working except when i went to run my error message if no records have been found. I have been looking for an answer and believe it is something to do with the result returning -1 but have no idea how to fix the issue.
Here is the code and thanks for any help
<?php
require_once('databaseconnection.php');
$keywordentered = $_GET['keyword'];
switch($_GET['type']) {
case 'ordernumber':
$result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Order_No LIKE '".$keywordentered."%'");
break;
case 'partnumber':
$result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Part_No LIKE '".$keywordentered."%'");
break;
case 'accountname':
$result = odbc_exec($odbc, "SELECT * FROM orderpartnumbertable WHERE Account_Name LIKE '".$keywordentered."%'");
break;
}
if(odbc_num_rows($result) == 0){
echo("Sorry your query has returned no results!");
exit;
}
echo '<table border=1>';
echo '<tr><th>Order Number</th><th>Part Number</th><th>Account Name</th><th>FNP Site</th><th>More Info</th></tr>';
while (($row = odbc_fetch_array($result)) !== false) {
echo '<tr>';
echo '<td>' . $row['Order_No'] . '</td>';
echo '<td>' . $row['Part_No'] . '</td>';
echo '<td>' . $row['Account_Name'] . '</td>';
echo '<td>' . $row['FNP_Site'] . '</td>';
echo '<td>' . '<a href="ordersearchdetails.php?fnp_site=' . rawurlencode($row['FNP_Site']) . '">More Info</a>' . '</td>';
echo '</tr>';
}
echo '</table>';
?>
This is the contents of my connection file
$odbc = odbc_connect ('orderpartsearchconnection', 'root', '') or die ('could not connect to ODBC Database!');
Cheers