Re: Search Script
| From: | Jennifer Downey | Date: | Thu, 25 Apr 2002 16:43:39 +0000 |
| Subject: | Re: Search Script | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18808@lists.php.net to get a copy of this message | ||
Thanks all,
You people are awesome. I have it working but I still have 2 bugs
First it is only showing the first record it finds with the search term, not
all records associated with it.
Second it has to be spelled exactly right or I get 0 results.
in other words if Jelly is spelled Jelly and I type jelly I get nothing but
if I spell it Jelly it will return only the first record it finds what have
I done wrong?
if($search)
{
$query = "SELECT uid, id, image, iname, quantity, user, type, price FROM
{$config["prefix"]}_shop WHERE iname LIKE '%$searchword%' ORDER BY iname";
$ret = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($ret))
{
$user = $row['user'];
$uiid = $row['uid'];
$iid = $row['id'];
$image = $row['image'];
$iname = $row['iname'];
$q = $row['quantity'];
$type = $row['type'];
$price = $row['price'];
}
if($searchword == $iname)
{
echo "<TABLE BORDER='0' WIDTH='95%' CELLPADDING='0'
CELLSPACING='0'><TR>";
echo "<TD width=20%><a
href='remove.php?id=$id&remove=yes'>$user</a></TD>";
echo "<TD width=40%><font size=2>$iname</font></TD>";
echo "<TD width=20%><font
size=2><CENTER>$q</CENTER></font></TD>";
echo "<TD width=30%><font
size=2><CENTER>$price</CENTER></font></TD>";
echo "</TD></TR></TABLE>";
}
}else{
echo "<FORM METHOD=post ACTION='$PHP_SELF'>";
echo "Search Shops<BR><input type=text name=\"searchword\"
value=\"\">";
echo "<BR><INPUT TYPE='submit' NAME='search'
VALUE='Search'>";
}
Thanks
Jennifer
"Jennifer Downey" <jendowney@attbi.com> wrote in message
news:20020425141620.75561.qmail@pb1.pair.com...
> Hi all,
>
> I have been trying to build a search script for my site that deals with
only
> one table in my db.
> As Julie Meloni pointed out look in the MySQL manual for LIKE clauses I
> can't seem to locate that clause in ether
> manual.
> Dan Brunner gave me this to go on:
>
> $query = "SELECT uid, id, image, iname, quantity, type FROM
> {$config["prefix"]}_shop WHERE iname LIKE = '%$shopsearch% ORDER BY
> iname'";
> $ret = mysql_query($query);
> while(list($quantity)=mysql_fetch_row($ret))
>
> But I can't seem to get this to work. I have never worked with LIKE before
> and would appreciate any help on this.
>
> Thanks Julie and Dan for your time and effort.
>
> Thanks all for your time and help
> Jennifer
>
>
> --
> The sleeper has awaken
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002