Search...
Moderator: General Moderators
Search...
Hy!
I have a 'search function' that searches through all tables in my DB (everywhere), through table users (users) or through table cars (cars) - (in brackets are three options of my dropdown)...
How can I search name of the user and surname at the same time, so I have:
Search: User-name_user-surname (users)
After space, 'query' ignores other searching values.
Thanks!
I have a 'search function' that searches through all tables in my DB (everywhere), through table users (users) or through table cars (cars) - (in brackets are three options of my dropdown)...
How can I search name of the user and surname at the same time, so I have:
Search: User-name_user-surname (users)
After space, 'query' ignores other searching values.
Thanks!
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Search...
Do a query like this:
"SELECT * FROM users WHERE FirstName LIKE '%" . $name . "%' OR LastName LIKE '%" . $lastname ."%'"
"SELECT * FROM users WHERE FirstName LIKE '%" . $name . "%' OR LastName LIKE '%" . $lastname ."%'"
Re: Search...
This isn't working for me...
I have:
$data = mysql_query("SELECT * FROM users WHERE name LIKE '% ". $find ." %' OR surname LIKE '% " . $find ." %'");
I have:
$data = mysql_query("SELECT * FROM users WHERE name LIKE '% ". $find ." %' OR surname LIKE '% " . $find ." %'");
Re: Search...
Can someone help me please? Thanks!
Re: Search...
You have a space after % in your query. and before the %
Change it to LIKE '%". $find ."%'
Change it to LIKE '%". $find ."%'
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Search...
No, I don't have spaces before and after % in my code, I must have misstyped myself here...
Re: Search...
Do a var_dump($find); before your query. This is to check the value of $find before the query is executed.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Search...
For john miller I get:
string(11) "john miller"
but still nothing was found...
So, I have field name and field surname in table users, I search with keywords 'name surname' and nothing is found.
I've also tried this:
$lines=split(" ", $find); // $find is variable for input
for ($i=0;$i<count($lines);$i++) {
$data=mysql_query("SELECT * FROM users WHERE name LIKE '%".$find."%' OR surname LIKE '%".$find."%'"); }
No success...
string(11) "john miller"
but still nothing was found...
So, I have field name and field surname in table users, I search with keywords 'name surname' and nothing is found.
I've also tried this:
$lines=split(" ", $find); // $find is variable for input
for ($i=0;$i<count($lines);$i++) {
$data=mysql_query("SELECT * FROM users WHERE name LIKE '%".$find."%' OR surname LIKE '%".$find."%'"); }
No success...
Re: Search...
try...ursl40 wrote: $data = mysql_query("SELECT * FROM users WHERE name LIKE '% ". $find ." %' OR surname LIKE '% " . $find ." %'");
Code: Select all
$data = mysql_query("SELECT * FROM users WHERE CONCAT_WS( ' ', name, surname) LIKE '%". $find ."%'")Re: Search...
ursl40 I would recommend you to try using Solr
Re: Search...
Can I use this with PHP pages, how? Thanks!
Re: Search...
With Your suggestion, it throws me a warning:mikosiko wrote:try...ursl40 wrote: $data = mysql_query("SELECT * FROM users WHERE name LIKE '% ". $find ." %' OR surname LIKE '% " . $find ." %'");pay attention that is one space here : ' 'Code: Select all
$data = mysql_query("SELECT * FROM users WHERE CONCAT_WS( ' ', name, surname) LIKE '%". $find ."%'")
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ...x.php on line y