Jump to content

php mysql fulltext search index help plz -> I am a newbie for php and mysql


underwinefx

Recommended Posts

I tried to implement the "similar article" tutorials available in internet using "FULLTEXT" search index. The database -"quotation" contains a table "quotation_list" with two fields -> "quotation_id" and another text field "quote" with quotations (or any text data).

The precise method said in the tutorial is as follows;
1. use some method to separate the data stored in text field using <space> as separator to get each word of the quotation separately.
2. Now, each 'data'(word) retrieved by the explode function is compared using "MATCH" function with the text data field "QUOTE"
3. Now, the matching "quotation_id" (numeric PRIMARY KEY field of the table) are listed as a list side by side for eg; as follows:
RELATED QUOTE NO: 1, 4, 5, 6, 7

I am able to display the entire list of data in a single page:

[code]
<?php
Code begins
//Database details to connect to mysql server
$username="username";
$password="password";
$database="quotation";

//Mysql Database Connection
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

//Mysql Query to retrieve quotation id and the quotation from quotation table
$result=mysql_query("SELECT * FROM quotation");

//Getting the number of rows of result from the query to be used in the loop to display results...
$num=mysql_num_rows($result);

//Title of the page
echo "<b><center>List Of Quotation</center></b><br><br>";

//Loop to get the data

$i=0;
while ($i < $num) {

$quotation_id=mysql_result($result,$i,"quotation_id");
$quotation_text=mysql_result($result,$i,"quotation_text");

//Data output on page one below the other
echo "Quote No:<b>$quotation_id</b><br>Quote: $quotation_text<br><hr><br>";
$i++;
}
//end of code
?>
[/code]

But I have difficulty in using the php mysql coding to retrieve the related data and displaying it. I want the related quotation numbers displayed below every quote automatically.

Since I am new to the forum and do NOT know if displaying the external link of the tutorial that I read to try to add the related quote function to this code, I am NOT adding the link here.

Now, actually I would be happy to have a single quote output per page with a list of all related text data...I mean, the quotation id and quotation in a single page instead of having the entire quotation list in the same page.

The rough idea is as follows:
[quote]
Page 1:
<previous page link><next page link>
[hr]
Quote No: <quotation_id>
Quote 1: <quote text>
[hr]
Related Quotes:
related quote id 1
related quote 1

related quote id 2
related quote 2

........
......
.....
..
[hr]
<previous page> <next page>
[/quote]

Can someone help me with this? Pagination is NOT a necessity and I would be perfectly content with even a simple script since I am going to use it only locally on my system for my personal use.

Regards,
underwinefx
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.