SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Searching mySQL with PHP
-
Aug 25, 2000, 16:33 #1
- Join Date
- May 2000
- Location
- London
- Posts
- 283
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OK, one of the great things about storing all your stuff in databases is that it can be searched easily right ?
So how the heck do i go about creating a search form for my site ? I really have no clue as to how to go about the SELECT statements etc.
Please help ASAP :-)
-James
-
Aug 25, 2000, 16:58 #2
- Join Date
- Jul 1999
- Location
- Chicago
- Posts
- 2,629
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
First of all, check out Kevin's tutorial. That will answer a lot of your questions. Then visit http://www.phpbuilder.com and read some there. That'll get all of your leftover questions.
But here's how to use a SELECT statement to search.
SELECT
all relevant fields separated by commas, required to show results
FROM
the table where the content being searched is
WHERE
here's where you filter the results. Maybe WHERE TITLE LIKE '%$string_to_search%'
;
-
Aug 25, 2000, 17:00 #3
- Join Date
- May 2000
- Location
- Canada
- Posts
- 533
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
as i was telling you in our chat :
SELECT * FROM table,table2,table3 WHERE table.html_of_page LIKE '$string_to_search%' AND table2.html_whatever LIKE '%$string_to_search%';
something in that form
------------------------------
myONLYhost: when you want something MORE
-
Aug 25, 2000, 17:33 #4
- Join Date
- May 2000
- Location
- London
- Posts
- 283
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
$result = mysql_query(
"SELECT * FROM news,reviews,interviews,articles WHERE articles.body LIKE '%$term%' AND lps.reviewtext LIKE '%$term%' AND eps.reviewtext LIKE '%$term$' AND singles.reviewtext LIKE '%$term%' AND interviews.body LIKE '%$term%' ");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
while ( $row = mysql_fetch_array($result) ) {
WWWWwwhhhhhhhhhhatgoeshere
}
would this work ? and what would be pushed into the array ?
Bookmarks