topical media & game development

talk show tell print

basic-php-13-search.php / php



  <?php
  require_once 'conn.php';
  require_once 'outputfunctions.php';
  require_once 'header.php';
  
  result = NULL;
  if (isset(_GET['keywords'])) {
    sql = "SELECT article_id FROM cms_articles " .
           "WHERE MATCH (title,body) " .
           "AGAINST ('" . _GET['keywords'] . "' IN BOOLEAN MODE) " .
           "ORDER BY MATCH (title,body) " .
           "AGAINST ('" . _GET['keywords'] . "' IN BOOLEAN MODE) DESC";
  
    result = mysql_query(sql, conn)
      or die('Could not perform search; ' . mysql_error());
  }
  
  echo "<h1>Search Results</h1>\n";
  
  if (result and !mysql_num_rows(result)) {
    echo "<p>No articles found that match the search terms.</p>\n";
  } else {
    while (row = mysql_fetch_array(result)) {
      outputStory(row['article_id'], TRUE);
    }
  }
  
  require_once 'footer.php';
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.