Hi. I've got a form that is passing the description varaible to this php coding to do a product search, based on the decription. Here is what I need help with:
1. I need to change the coding (add wild cards??) to do display all the results that match the word(s) of the search. The results for each match should show the entire Description (descr), the Cost, Manufacturer Part Number (manu_part), and our Part Number (part_num).
2. How do I display all the results. Right now I can only search the database and get a match if I search for a specific descrption of a product. Plus, my coding only outputs one result. How can I make it so that I can output more than one search result? (An array??)
Here what I've got done so far:
<?
//Connection Variables
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "";
//Connect
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db("$dbname",$db);
//Query
$query = mysql_query("SELECT descr, cost, manu_part, part_num FROM products WHERE part_num ='$description'");
list($descr, $cost, $manu_part, $part_num) = mysql_fetch_row($query);
//Add Percentage & Round
function add_percent ($price, $percent) {
$newprice = $price * (1 + ($percent/100));
return number_format($newprice,2);
}
//Display Results
print ("\n <U>Product Number:</U> $id <P>");
print ("\n <U>Description:</U> $descr <P>");
print ("\n <U>Our Price: </U> $".add_percent($cost, 15));
print ("<P>");
?>
ANY help will be greatly apreciated!
1. I need to change the coding (add wild cards??) to do display all the results that match the word(s) of the search. The results for each match should show the entire Description (descr), the Cost, Manufacturer Part Number (manu_part), and our Part Number (part_num).
2. How do I display all the results. Right now I can only search the database and get a match if I search for a specific descrption of a product. Plus, my coding only outputs one result. How can I make it so that I can output more than one search result? (An array??)
Here what I've got done so far:
<?
//Connection Variables
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "";
//Connect
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db("$dbname",$db);
//Query
$query = mysql_query("SELECT descr, cost, manu_part, part_num FROM products WHERE part_num ='$description'");
list($descr, $cost, $manu_part, $part_num) = mysql_fetch_row($query);
//Add Percentage & Round
function add_percent ($price, $percent) {
$newprice = $price * (1 + ($percent/100));
return number_format($newprice,2);
}
//Display Results
print ("\n <U>Product Number:</U> $id <P>");
print ("\n <U>Description:</U> $descr <P>");
print ("\n <U>Our Price: </U> $".add_percent($cost, 15));
print ("<P>");
?>
ANY help will be greatly apreciated!