Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 1.76 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. error_reporting(E_ALL ^ E_NOTICE); // Deffo turned on here.
  3. date_default_timezone_set('UTC');
  4.  
  5. $submit = $_POST['submit'];
  6. $query = $_POST['search'];
  7.  
  8. $query = addslashes($query);
  9.  
  10. if (empty($submit)) {
  11.         die('Post variables did not come through');
  12. }
  13.  
  14. // Lets connect to the database
  15.  
  16. $mysqli = new mysqli('localhost', '403140_eltanews', '5u30nlyELTA', '403140_eltagroup');
  17.  
  18. //let's produce an error if we couldnt connect
  19. /* check connection */
  20. if (mysqli_connect_errno()) {
  21.     printf("Connect failed: %s\n", mysqli_connect_error());
  22.     exit();
  23. }
  24.  
  25. if ($results = $mysqli->query("SELECT * FROM `eltagroupnews` WHERE MATCH (`content`, `title`, `para1`) AGAINST ('".$query."' IN BOOLEAN MODE)"))
  26. {
  27.         $num_rows = $results->num_rows;
  28.         if ($num_rows > 0) {
  29.                 while ($row = $results->fetch_assoc()) {
  30.                         $query = stripslashes($query);
  31.                         $new_para1 = preg_replace('/'.$query.'/', '<span class="hilite">'.$query.'</span>', $row['para1']);
  32.                         echo '<div class="results2">';
  33.                         echo '<div class="content-within"><u style="color:#007CCC;"><span class="title"><a href="article/'.$row["year"].'/'.$row["slug"].'.html">'.stripslashes($row['title']).'</a></span></u><br />';        
  34.                         echo '<p class="resultblurb">'.substr(stripslashes($new_para1), 0, 500).'</p>';
  35.                         echo '<a href="http://www.eltagroup.com/article/'.$row['year'].'/'.$row['slug'].'.html"><span class="link">http://www.eltagroup.com/article/'.$row['year'].'/'.$row['slug'].'.html</span></a></div>';
  36.                        
  37.                         echo '<div class="logo-container"><img class="left-logo" src="images/news/'.$row['company_logo'].'" /></div>';
  38.                         echo '<div class="clear"></div></div><br />';
  39.                 }              
  40.                
  41.         } // end of number of rows if
  42. }
  43. else {
  44.         die('query to database did not work '. $mysqli->error);
  45. }
  46. $mysqli->close();
  47.  
  48.  
  49.  
  50. ?>