Jump to content

partial search, please help


phpnewbie770

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>";
Link to comment
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
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.