Jump to content

Archived

This topic is now archived and is closed to further replies.

phpnewbie770

partial search, please help

Recommended Posts

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>";

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.