Welcome to WebmasterWorld Guest from 54.145.39.186

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Simple database search engine

     

mikejs

12:26 pm on Nov 5, 2009 (gmt 0)

5+ Year Member



Hi I would like to build a simple full text search database

The database will hold a variety of information on a perticular topic Cars for example I would like to be able to stroe images and text in the database and then have a serch box which will return the results from the database and display them on the page

any suggestions

thanks

M

mikejs

12:23 pm on Nov 6, 2009 (gmt 0)

5+ Year Member



Hi ok I have built a simple database with a table

articles id, catagory, title, body, rate

I have built a simple form which I will use to update the database with new articles

I have 3 text boxes catagory, title and body

I would like to validate the form before its submitted to check all the form fields have been compleated

it then posts the data to a simple php form that passes the data to the DB

the form works fine but after submitting the form I get now notice back saying update was ok

if possible on the new article form I would like to be able to display a list of all the articles on the database and then after a new record has been created return the user to the form where the new entry will apear

anyone have any sugestions or links I could use

thanks

M

eelixduppy

2:56 pm on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



[webmasterworld.com...]

There's a thread from our library that will help you get started. Once you get something to start with we can go from there if you need additional help. :)

mikejs

5:39 pm on Nov 6, 2009 (gmt 0)

5+ Year Member



Thanks for the reply I am getting there slowly I have creted a front end and a upload new article page so far so good

I will sort out the main search later its not that dificult just a case of running a full text search accross the tb and then displaying the results :-)

I have created a dynamic list box I would like to use it to run some quiries

<?php
mysql_select_db($database,$connect) or die ("error cannot connect");

$result = mysql_query($database,$connect);

$query="SELECT name,id FROM category";

$result = mysql_query ($query);
echo "<select name=name value=''>Catagory Search</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[name]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>

say the list box selected is asp.net I want to be able to run a query to display the selected catagory

somthing like select * from . $selected .

how can I add the selected value into the query thanks

M

rocknbil

6:46 pm on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



With the where clause in your select [dev.mysql.com].

Optimizing where clauses [dev.mysql.com] for more info.

JohnCanyon

9:31 pm on Nov 6, 2009 (gmt 0)

10+ Year Member



Something else to consider is the Apache Lucene project. The zend framework offers the ability to easily set up a very powerful text search engine leveraging lucene.

Out of the box you are going to get more mileage from this system than trying to write your own.

Lucene gives you the ability to do more complex searches such as mutli column only searches to:

keyword: "flight:191 destination:new york"

or regular searches..

keyword: "191 new york"

mikejs

11:12 am on Nov 8, 2009 (gmt 0)

5+ Year Member



Thanks for the replies I have put the following together

<?php
if (count($_POST) > 0) {
$search = trim(strtoupper($_POST['searchtxt']));

mysql_select_db ("microsearch")
or die ("Cannot connect to the database");

//run query on database where search value is like table fields
$sql = "SELECT * FROM articles where ( ";
$sql .= " UPPER(title) like '%" . $search . "%' OR ";
$sql .= " UPPER(category) like '%" . $search . "%' OR ";
$sql .= " UPPER(body) like '%" . $search . "%' ";
$sql .= ") order by category";

$q = (mysql_query($sql));
echo $q;
$num_rows = mysql_num_rows($q); ///check no of rows

// while there are rows echo output to produce page of results
if($num_rows>0){
while($d = mysql_fetch_array($q)){
$id = $d['id'];
$title = $d['title'];
$category = $d['category'];
$body = $d['body'];

echo "<div class=\"response\"><p><strong>" . $title . "</strong></p>";
//include("resultsheader.php");
echo $id . ' - ';
echo '<br>';
echo 'Category: ' . $category . '<br>';
echo '<br>';
echo 'Body: ' . $body . '<hr>';
echo "</div>";
}
//end while loop

}else{
echo"<p>Sorry, no search result. Please change keywords and try again.</p>";
}//end if

I need to paginate the results anyone have any sugestions

thanks

M

rocknbil

8:13 pm on Nov 8, 2009 (gmt 0)

mikejs

3:29 pm on Nov 9, 2009 (gmt 0)

5+ Year Member



Thanks for the reply I think I was looking for a more hands on reply based on my supplied code...

:-) I will continue reading...

rocknbil

6:44 pm on Nov 9, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Sorry, would have answered more directly but it's a little complex and the approach may vary, as you can see by some of the threads found there.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month