Re: Simple search engine gone bad
| From: | Jennifer Downey | Date: | Tue, 30 Apr 2002 15:52:16 +0000 |
| Subject: | Re: Simple search engine gone bad | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18907@lists.php.net to get a copy of this message | ||
Thanks all for your help.
I knew it was somathing stupid and I knew it was because it was Monday.
Now that it is Tues I have found the problem and it was somethin very
stupid.
I forgot
echo "</FORM>";
Now it work as it should.
Again thanks
Jennifer.
"Jennifer Downey" <jendowney@attbi.com> wrote in message
news:20020430013309.51981.qmail@pb1.pair.com...
> Hi all,
>
> It's Monday, it's probably something stupid, but I have poured over this
all
> day and cannot find the problem.
> This is a simple search engine based on one table. It is suppose to return
> the results of the search word. Instead it returns ALL records in the
mysql
> table. If I type the letter x and there are no words in the table with an
x
> I still get all records returned.
>
> Would someone be kind enough to show me what I have done wrong.
>
>
> if($search)
> {
> $query = "SELECT iname, quantity, user, price FROM
> {$config["prefix"]}_shop WHERE iname LIKE '%$searchword%' AND price > 0
> ORDER BY price";
> $ret = mysql_query($query) or die(mysql_error());
> while($row = mysql_fetch_array($ret))
> {
> $user = $row['user'];
> $iname = $row['iname'];
> $q = $row['quantity'];
> $price = $row['price'];
>
> if($searchword = $iname)
> {
> echo "<TABLE BORDER='0' WIDTH='95%' CELLPADDING='0'
> CELLSPACING='0'><TR>";
> echo "<TD width=20%><a
> href='usershop.php?user=$user'>$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'>";
>
>
> }
>
>
> Thank you
> 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/20/2002