Jump to content


Photo

partial search, please help


  • Please log in to reply
1 reply to this topic

#1 phpnewbie770

phpnewbie770
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 25 March 2006 - 06:58 PM

I am trying to create a search where users can enter part of an article title, and have it bring up all article titles with that word or words in it. My database contains very simply, a table called newslink with fields called article - the titles (to be searched), link - the urls, and other (varchar).

I want it to search the article field, and display the article titles with the url.

I have the majority of it straight(part of it is in french as the original creator was canadian) but my display shows ALL my articles, not just the ones from the search. Below is a portion of the code (which I believe needs corrections). Please advise.

$newlink = $_POST["newslink"];


$where = " other='x' ";

if ( $newslink != '' ) {
$where = $where . " AND newslink='" . str_replace ( "'", "''", $newslink) . "'";
}





print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\"><HTML><HEAD> ");
print("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;CHARSET=iso-8859-1\"> ");
print("<META NAME=\"robots\" content=\"index,follow\"> ");
print("<META NAME=\"description\" CONTENT=\"data\"> ");
print("<META NAME=\"keywords\" ");
print("CONTENT=\"natural,health,care,pro\"> ");
print("<META NAME=\"reply-to\" CONTENT=\"gperon@kapservices.com\"> ");
print("<META NAME=\"owner\" CONTENT=\"nhp\"> ");
print("<META NAME=\"revisit-after\" CONTENT=\"3 days\"> ");
print("<link href=\"communique.css\" rel=\"stylesheet\" type=\"text/css\"> ");
print("<TITLE>Newslink Search</TITLE></HEAD>");
print("<BODY> ");
//print("Powered by <b>KAP<i><font color=\"#FF0000\">");
//print("Services</font></i></b><i><font color=\"#FFFFFF\">.com</font></i><br>");
print("<center>");
print("<br><a href=\"search_submit_newslink.php\" class=\"text_label_titre\"> ");
print("Click here to make another search</a><br><br>");
print("<table BORDER=\"0\" WIDTH=\"500\" ");
print("cellspacing=\"1\">");

//print "SELECT * FROM newslink WHERE ".$where." ORDER BY `number` DESC ";




$requete = mysql_query("SELECT * FROM newslink WHERE ".$where." ORDER BY `number` DESC ");


while ($ligne = mysql_fetch_array($requete)) {




if ($ligne["article"] != "" ) {
print( "<br><b>Newslink: </b> <a href=\"".$ligne["link"]."\" target='_blank'> ");
print( $ligne["article"] );
print( "</a>");
}













}
print "<br><br>";

#2 swatisonee

swatisonee
  • Members
  • PipPipPip
  • Advanced Member
  • 253 posts

Posted 26 March 2006 - 12:57 PM

See this link. make the change as indicated by kenbrsn in the penultimate post and it give you the list. You can remove the choice radio buttons and such...

[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=89193&hl=\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...topic=89193&hl=[/a]

HTH

Shishya




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users