php3-list | 199807
Date: 07/05/98
- Next message: Giancarlo Pinerolo: "Re: [PHP3] does SetCookie need a wait?"
- Previous message: Rasmus Lerdorf: "Re: [PHP3] randon number"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi!
I try to convert an app I have written for msql/php2 to
work with mysql/php3.
based on two variables which are set in a html form ($keyword and $category) a query is
send to the db which in the first case should output everything that maches $keyword
(works). In the second case it should output everything that matches a second variable
($category), too.
It was like this (working fine):
-------------------------------------------------------------------------------------------------
<?if($category=="Alle Kategorien");
$result = msql($database,"select url,description,category,id from urls where url
clike '%$keyword%' or description clike '%$keyword%' order by description");
$num = msql_numrows($result);
else;
$result = msql($database,"select url, description, category,id from urls where
category='$category' and url clike '%$keyword%' or description clike '%$keyword%' order
by description");
$num = msql_numrows($result);
endif;.......
-------------------------------------------------------------------------------------------------
New version looks like this:
-------------------------------------------------------------------------------------------------
<?php if($category=="Alle Kategorien"):
$result = mysql_query("select url,description,category,id from urls where url LIKE
'%$keyword%' or description like '%$keyword%' order by description");
$num = mysql_num_rows($result);
else:
$result = mysql_query("select url, description, category, id from urls where
category='$category' AND url LIKE '%$keyword%' OR description like '%$keyword%'
ORDER BY description");
$num = mysql_num_rows($result);
endif;
-------------------------------------------------------------------------------------------------
The second SELECT works when I just use the AND part and gives just the matching data:
select url,.., id from urls where category='$category' AND url LIKE '%$keyword%'
it does not work when I add the second OR condition:
...OR description like '%$keyword%' ORDER BY description");
it just outputs everything in the table.
any hint available?
----------------------------------------------
Dipl.- Ing. Axel Hosek
Consulting Internetprojekte
o.tel.o communications, Geschaeftsbereich Grosskunden
63263 Neu-Isenburg Tel: 06102-701-319 Fax: 06102-701-349
-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.tryc.on.ca/php3.html
- Next message: Giancarlo Pinerolo: "Re: [PHP3] does SetCookie need a wait?"
- Previous message: Rasmus Lerdorf: "Re: [PHP3] randon number"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

