Define SQL search queries with PHP
| From: | Alan Lam | Date: | Wed, 26 Mar 2003 09:00:46 +0000 |
| Subject: | Define SQL search queries with PHP | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-8912@lists.php.net to get a copy of this message | ||
I'm afraid this is more of a php question than smarty, but I'm stuck on this problem with
sql queries. Sorry to trouble you all with this.
$result = func_query("SELECT categoryid, FROM $sql_tbl[categories] WHERE category LIKE
'".addslashes($category_name)."%'");
I'm trying to search the query from $category_name (ie. Computer/Hardware/Joystick ) and return
the string before the last "/"(ie. Computer, Computer/Hardware).*note queries can return
Computer, Computer/Hardware, Computer/Hardware/Joystick, I need the search to return strings without
slash as well...* I've modified it to this:
WHERE category LIKE '"strrev( strchr(strrev($category_name),"/") )'");
I also tried !strstr($category_name,"/") as well, but no cigar...
but displaying the page gives me a Parse error on top. What am I doing wrong with the code?
Distressed, thanks in advance to all of you!
Alan Lam
alan@goodorient.com.cn
Web Developer
www.goodorient.com