Okay, I'm building a form where a person would enter their customer code, and then I do a query on a database based upon their customer code.
I'm piping out all of the customer's item codes into one drop down box, and my problem is this. Since my company has repeat customer's, some of the rows in the database have repeat item codes, so I need some way of filtering out the item codes that are duplicated.
Here's a snippet of my code:
$dbcx = odbc_connect("GROSSMARGIN","usernamehere","passhere",SQL_USE_CUR_DRIVER);
$cur1=odbc_exec($dbcx,"select * from opcsahf where cust_code = '$custcode'");
while (odbc_fetch_row($cur1))
{
$compare = strval($item_code);
$item_code = odbc_result($cur1,5);
if ($compare != $item_code)
{
@$option_block .="<option value=\"$item_code\">$item_code</option>";
}
}
echo "<select name=itemcode>";
echo "$option_block";
echo "</select>";
As you can see, I tried to immediately put the contents of $item_code into $compare and then do an if statement based on the fact of them not being equal. However, since the same itemcode could creep up on say, the fifth row query, it would be included because it wouldn't be equal to what $item_code is at that precise time.
Hopefully that made some sort of sense...
Any help is appreciated as always.