Here is my test2.php File this is all the code im using and after the code i have pasted a sample of what my Table Looks like.
No mater what i search for it will allways return all of the data that i have in the table but if i just use a select line like this.
$sql = "SELECT * FROM coffee_inventory WHERE roast_type LIKE '%$sbox%'";
It works perfectly but i need it to search each field for what the user entered. i have tried to make the script do multipul querys but that will result in doubles of items
Any help is greatly Appreciated
Thanks, Robert
---( Test2.php )---
<head><title>Digital Playground - PHP Database Gateway</title></head>
<body bgcolor=#000000 text=#FFFFFF>
<img src=/images/title.jpg>
<br><hr><p>
<center>
<table>
<tr><td width=800>
<?php
if (!$submit)
{
echo "<center><form method=get action=index.php>
<INPUT TYPE=TEXT NAME=sbox MAXLENGTH=100 SIZE=40 VALUE= >
<INPUT TYPE=submit NAME=submit VALUE= search >
</form>
<p><font face=arial,helvetica size=-1>
Enter <B>one or more words</B> to search for. If you want to specify more than one word,
use a space as a separator. Example : <I>death dismemberment</I> for all topics dealing
with both death and dismemberment.</font></center>";
}
?>
<?php
if ($submit)
{
$xcount = 0;
$connection = mysql_connect("localhost","user","pass");
if (!$connection) { echo "Couldn't make a connection!"; exit; }
$db = mysql_select_db("myDB", $connection);
if (!$db) { echo "Couldn't select database!"; exit; }
$sql = "SELECT * FROM coffee_inventory WHERE roast_type OR coffee_name OR quantity OR link LIKE '%$sbox%'";
$sql_result = mysql_query($sql,$connection);
echo "<CENTER><TABLE BORDER=1 width=640>";
echo "<TR><TH>Coffee Name</TH><TH>Roast Type</TH><TH>Quantity</TH><TH>Links</TH>";
while ($row = mysql_fetch_array($sql_result))
{
$coffee_name = $row["coffee_name"];
$roast_type = $row["roast_type"];
$quantity = $row["quantity"];
$link = $row["link"];
echo "<TR><TD> $coffee_name </TD><TD> $roast_type </TD><TD> $quantity </TD><TD><CENTER> $link </CENTER></TD></TR>";
$xcount = $xcount + 1;
}
echo "<P><b>$xcount Results found for:</b> $sbox";
echo "</TABLE></CENTER>";
echo "<p><center><a href=javascript:history.go(-1)>Return to Main Search Page</a></center>";
mysql_free_result($sql_result);
mysql_close($connection);
}
?>
</td></tr>
</table>
</center>
</body>
---( END Test2.php )---
Here is what my database looks like:
DB: myDB
Table: Coffee_Inventory
Fields:
Coffee_Name, Roast_type, Quantity, Link
Data:
coffee1 dark 36 www.coffee1.com
coffee2 medium 31 www.coffee2.com
coffee3 dark 56 www.coffee3.com
coffee4 light 12 www.coffee4.com
coffee5 dark 26 www.coffee5.com
coffee6 medium 41 www.coffee6.com
coffee7 light 23 www.coffee7.com
And as far as Setting things as Primary or Indexed or things like that i have no clue what they are so i dident use them
I hope this will help you help me.