I don't know why the following script is returning 0 rows. Before I added the $brandselect drop-down box to fine-tune the choice, everything was working fine.
When $where used to be ...PHP Code:<?php
if (isset($_POST['text']))
{
if (!preg_match('|^[ .0-9a-zA-Z -]+$|' , $_POST['text']))
exit("<p class='msgbanner2'><strong>Please try again without using punctuation.</strong></p>");
}
// $text is info typed into search box.
// $cols is the radio button checked for the number of columns desired.
// $brandselect is the brand selected.
$text = $_POST['text'];
$text = strtolower($text); // MAKE LOWERCASE
$text = strip_tags($text); // REMOVE SYMBOLS
$text = trim($text); // REMOVE ANY EXTRA WHITE SPACE AT END OF LINE
$text = htmlspecialchars($text);
$cols = $_POST['cols'];
$cols = strtolower($cols); // MAKE LOWERCASE
$cols = strip_tags($cols); // REMOVE SYMBOLS
$cols = trim($cols); // REMOVE ANY EXTRA WHITE SPACE AT END OF LINE
$cols = htmlspecialchars($cols);
$brandselect = $_POST['brandselect'];
$brandselect = strtolower($brandselect); // MAKE LOWERCASE
$brandselect = strip_tags($brandselect); // REMOVE SYMBOLS
$brandselect = trim($brandselect); // REMOVE ANY EXTRA WHITE SPACE AT END OF LINE
$brandselect = htmlspecialchars($brandselect);
// If chose to search within single brand
$where = "WHERE (PartNo LIKE '$text' OR ItemName LIKE '%$text%' OR Descr LIKE '%$text%') AND Brand = '$brandselect'";
// If chose to search among all brands ("allbrands" in drop-down box)
if ($brandselect == 'allbrands')
{ $where = "WHERE PartNo LIKE '$text' OR ItemName LIKE '%$text%' OR Descr LIKE '%$text%'"; }
$plq = mysql_query
( "SELECT Photo, PartNo, ItemName, MSRP, Descr, Brand, DateCreated
FROM aeproducts
$where
ORDER BY DateCreated DESC"
);
$message = array(
"<p class='msgbanner1'><strong>ERROR. Please try again another time.</strong></p>",
"<p class='msgbanner1'><strong>Sorry, I cannot find that information. Please check your typing and try again.</strong></p>",
"<p class='msgbanner2'>You searched for <strong>$text</strong></p>",
"<p class='msgbanner2'><strong>Please try again without using punctuation.</strong></p>"
);
?>
... it worked fine. Now I want the value of "$Brand = reedy" to be dependent on a drop-down box to narrow the search further.PHP Code:WHERE (PartNo LIKE '$text' OR ItemName LIKE '%$text%' OR Descr LIKE '%$text%') AND $Brand = reedy
Thanks!
Steve






Bookmarks