Okay, I've created this little script that accesses my database and pumps out product codes based on a previously inputted customer code.
It all works fine, but now I'm trying to check so that if the customer inputted a customer code that doesn't exist in the database, the script will echo something like, "Sorry, that customer code doesn't exist."
Here's a bit of the code:
$custcode = strtoupper($custcode);
$dbcx = odbc_connect("GROSSMARGIN","usernamehere","passhere",SQL_USE_CUR_DRIVER);
$cur1=odbc_exec($dbcx,"select distinct item_code from opcsahf where cust_code = '$custcode'");
while (odbc_fetch_row($cur1))
{
$item_code = odbc_result($cur1,1);
if ($item_code == " "){
echo "Sorry, that customer code was not found in our database!";
}
else
{
if ($item_code == 'NONINVENTORY')
{
}
else{
@$option_block .="<option value=\"$item_code\">$item_code</option>";
}
}
}
echo "<select name=itemcode>";
echo "$option_block";
echo "</select>";
As you can see, I tried checking to see if $item_code was equal to well nothing, and that didn't work. If the customer code doesn't exist in the database, then the query should come out as false shouldn't it? I've tried a whole bunch of things and I'm stumped.
Thanks for any information.