LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-08-2005, 03:57 PM   #1
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Rep: Reputation: 15
How do list the results from my search form?


Iv got my insert and search script ready.
its just when i insert Zeb and insert something similar like Zeb2.
When i then try to search for say Zeb, it gives me the first title Zeb but lists the text from both Zeb and Zeb2

My search script:

PHP Code:
<?php


if (isset($_POST['searchfor']) && trim($_POST['searchfor']) != '')
{
  
texter();

  
$searchfor addslashes($_POST['searchfor']);
  
$sql="SELECT title, text FROM texts,details WHERE texts.textid=details.textid AND title LIKE '%".$searchfor."%';";
  
$result=mysql_query($sql$conn);

  if(
mysql_affected_rows()>0)
  {
    echo 
"Följande poster hittades:<br /><br />";
    while(
$row mysql_fetch_array($result))
    {
      
$details $row['title'];
      
$texts $row['text'];
      
printf("<B>%s</B><br /><textarea name=text COLS=80 ROWS=20>%s<textarea/>"$details$texts);
    }

  
mysql_free_result($result);
  }
  else
    echo 
"Inga poster hittades.<br /><br />";
}
?>

</html>
 
Old 05-08-2005, 06:00 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,672

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
PHP Code:
$sql="SELECT title, text FROM texts,details WHERE texts.textid=details.textid AND title LIKE '%".$searchfor."%';"
Since your sql statement uses the like term then the results will ouput any record with zeb in the title field. In your case that is two records zeb and zeb2.

Do you want to search for an exact match or that contains the search string?
 
Old 05-08-2005, 06:56 PM   #3
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Original Poster
Rep: Reputation: 15
i want it to list the possibilties or just not give any results if you spell wrong
 
Old 05-08-2005, 07:56 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,672

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Then IMO your sql statement does not require any changes.
 
Old 05-09-2005, 11:01 AM   #5
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Original Poster
Rep: Reputation: 15
But when i get similar results shouldnt it be appropiate with a list to select the title you were looking for?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
useful shortcut - pipe results of search to cp disorderly Linux - General 6 11-13-2010 11:09 AM
Search results page header lhoff LQ Suggestions & Feedback 4 09-14-2004 09:09 AM
The new Search Results page is not as good as the old one ? qwijibow General 2 07-25-2004 03:31 PM
search within results toastermaker LQ Suggestions & Feedback 1 11-20-2003 01:11 AM
Apollon: no search results m00nd0g Linux - Software 1 07-26-2003 05:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration