Trouble getting just one result.
Posted: Sat Feb 07, 2004 5:44 pm
Can someone help a real newbie? I want to return a single exact result not all related results. What am I ding wrong?
$pn = ($pn == "" ? $pn = "%" : $pn = $pn);
$description = ($description == "" ? $description = "%" : $description = $description);
$query = mysql_query("SELECT part_number,description,price,weight FROM suzukiparts WHERE part_number LIKE '%$pn%' AND description LIKE '%$description%'")or die(mysql_error());
if (mysql_num_rows($query) > 0) {
while(list($o_part_number,$o_description,$o_price,$o_weight) = mysql_fetch_row($query)) {
if (stristr($o_description, "USE PART#")) {
list($p1,$part_num) = explode("# ",$o_description);
print "<body bgcolor=\"orange\"><table border=\"0\"><font face=\"arial\" size=\"-1\"><center><b><h4>Updated Part Number, Click on new number <a href=\"spart3.php?pn=$part_num\">$part_num</a>\n";
}
else {
print "<body bgcolor=\"yellow\"><table border=\"0\" width=\"100%\" align=\"left\"><tr valign=\"top\"><td width=\"20%\"><b><big>Part# </b></big> $o_part_number</td><td width=\"25%\"><b><big>Desc </big></b> $o_description</td><td width=\"15%\"><b><big>Price</big></b> $o_price</td><td width=\"5%\"><b><big>Quantity </big></b></td><td width=\"20%\"><form METHOD=\"POST\" ACTION=\"http://www.alpha-sports.com/cgi-bin/cart.cgi\" type=\"image\" SRC=\"images/add2cart.gif\" alt=\"Add to cart...\" name=\"I1\" target=\"_self\"><input type=\"hidden\" name=\"return\" value=\"http://www.alpha-sports.com/footer.html\"><input type=\"hidden\" name=\"price\" value=\"$o_price\"><input type=\"hidden\" name=\"name\" value=\"$o_description\"><INPUT TYPE=\"TEXT\" NAME=quantity VALUE=\"1\" SIZE=\"2\" MAXLENGTH=\"2\"><input type=\"hidden\" name=\"custom1\" value=\"$o_description\"> <input type=\"hidden\" name=\"custom2\" value=\"Stock# $o_part_number\"> <input type=\"hidden\" name=\"sh\" value=\"$o_weight\"> <INPUT TYPE=\"HIDDEN\" NAME=\"redirect\" TARGET=\"main1\" VALUE=\"1\"> <input type=\"hidden\" name=\"add\" value=\"1\"><input alt=\"Add to cart...\" name=\"I3\" src=\"images/add2cart.gif\" type=\"image\"><INPUT TYPE=\"hidden\" name=\"redirect\" value=\"2\"></form><td width=\"5%\"><form METHOD=\"POST\" ACTION=\"http://www.alpha-sports.com/cgi-bin/cart.cgi\" target=\"_top\"><input alt=\"Go to shopping cart checkout...\" name=\"I4\" src=\"new_images/checkoutButton_61x22.gif\" type=\"image\"></form></td></tr></table>\n";
}
}
} else {
print "<body bgcolor=\"red\"><table border=\"0\"><font face=\"arial\" size=\"-1\"><center><b><h4>Part number is no longer in the price book. Email us the part number, model and description for the price.";
}
$pn = ($pn == "" ? $pn = "%" : $pn = $pn);
$description = ($description == "" ? $description = "%" : $description = $description);
$query = mysql_query("SELECT part_number,description,price,weight FROM suzukiparts WHERE part_number LIKE '%$pn%' AND description LIKE '%$description%'")or die(mysql_error());
if (mysql_num_rows($query) > 0) {
while(list($o_part_number,$o_description,$o_price,$o_weight) = mysql_fetch_row($query)) {
if (stristr($o_description, "USE PART#")) {
list($p1,$part_num) = explode("# ",$o_description);
print "<body bgcolor=\"orange\"><table border=\"0\"><font face=\"arial\" size=\"-1\"><center><b><h4>Updated Part Number, Click on new number <a href=\"spart3.php?pn=$part_num\">$part_num</a>\n";
}
else {
print "<body bgcolor=\"yellow\"><table border=\"0\" width=\"100%\" align=\"left\"><tr valign=\"top\"><td width=\"20%\"><b><big>Part# </b></big> $o_part_number</td><td width=\"25%\"><b><big>Desc </big></b> $o_description</td><td width=\"15%\"><b><big>Price</big></b> $o_price</td><td width=\"5%\"><b><big>Quantity </big></b></td><td width=\"20%\"><form METHOD=\"POST\" ACTION=\"http://www.alpha-sports.com/cgi-bin/cart.cgi\" type=\"image\" SRC=\"images/add2cart.gif\" alt=\"Add to cart...\" name=\"I1\" target=\"_self\"><input type=\"hidden\" name=\"return\" value=\"http://www.alpha-sports.com/footer.html\"><input type=\"hidden\" name=\"price\" value=\"$o_price\"><input type=\"hidden\" name=\"name\" value=\"$o_description\"><INPUT TYPE=\"TEXT\" NAME=quantity VALUE=\"1\" SIZE=\"2\" MAXLENGTH=\"2\"><input type=\"hidden\" name=\"custom1\" value=\"$o_description\"> <input type=\"hidden\" name=\"custom2\" value=\"Stock# $o_part_number\"> <input type=\"hidden\" name=\"sh\" value=\"$o_weight\"> <INPUT TYPE=\"HIDDEN\" NAME=\"redirect\" TARGET=\"main1\" VALUE=\"1\"> <input type=\"hidden\" name=\"add\" value=\"1\"><input alt=\"Add to cart...\" name=\"I3\" src=\"images/add2cart.gif\" type=\"image\"><INPUT TYPE=\"hidden\" name=\"redirect\" value=\"2\"></form><td width=\"5%\"><form METHOD=\"POST\" ACTION=\"http://www.alpha-sports.com/cgi-bin/cart.cgi\" target=\"_top\"><input alt=\"Go to shopping cart checkout...\" name=\"I4\" src=\"new_images/checkoutButton_61x22.gif\" type=\"image\"></form></td></tr></table>\n";
}
}
} else {
print "<body bgcolor=\"red\"><table border=\"0\"><font face=\"arial\" size=\"-1\"><center><b><h4>Part number is no longer in the price book. Email us the part number, model and description for the price.";
}