|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Creating a Search Application
I thought I would pass some comments on this tutorial.
I have found it to be greatly useful in my latest development project. I have been adapting it to my own database handlers using a postgress back end. I am using it index keywords from web pages stored in my database which were retieved using a web crawler written in PHP. Great work! Just having trouble getting the search form to pass the search terms to the search class. For some reason nothing is being passed through at the moment. This works from the search form: $search = new Search($_POST['search_term']); echo "===============<br>"; echo $_POST['search_term']; echo "<br>===============<br>"; But this ... $match = "keywords.keyword in ('" . $search[0] . "'"; $numwords = count ($search); for ($i = 1; $i < $numwords; $i++) { $match .= ", '" . $search[$i] . "'"; } $match .= ")"; $query = "SELECT harvest.url, keywords.keyword, " . "count(*) as counter " . "FROM harvest, keywords " . "WHERE $match " . "AND keywords.url_id = harvest.urlid " . "GROUP BY keywords.url_id, keywords.keyword, harvest.url " . "ORDER BY counter DESC"; echo $query; Gives: SELECT harvest.url, keywords.keyword, count(*) as counter FROM harvest, keywords WHERE keywords.keyword in ('') AND keywords.url_id = harvest.urlid GROUP BY keywords.url_id, keywords.keyword, harvest.url ORDER BY counter DESC Any advice would be most welcome. |
|
#2
|
|||
|
|||
|
RE: Creating a Search Application
How is the $search variable being populated?
|
|
#3
|
|||
|
|||
|
RE: Creating a Search Application
As per the tutorial, code below for the form:
<form method=POST action="<?= $_SERVER['PHP_SELF'] ?>"> <p><input type="text" name="search_term" size="20"> <input type="submit" name="submit" value="Submit"></p> </form> |
|
#4
|
|||
|
|||
|
RE: Creating a Search Application
I think that bit is working now, new error though:
Your search results: Warning: Invalid argument supplied for foreach() in search_form.php on line 24 Line 24 from search_form.php is: foreach($results as $row) { Preceding code is below: $results = $search->doSearch(); if($results) { echo "<p><b>Your search results:</b></p>n"; echo "<p>"; echo count($results); foreach($results as $row) { |
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > Creating a Search Application |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|