Location: PHPKode > projects > WH Community > wh_community/blog_search.php
<?php require('layout/header.php'); ?>

<div id="content_wrapper">
    <div class="content">
	
    	<div class="search"><?php
    	
    	echo '<h1><img src="images/icons/search.png">&nbsp;' . $lang['blog_search'] . '</h1><br>';
    
    	if(isset($_POST['submit'])) {
    	$problem = FALSE;
    	
    	if(empty($_POST['search'])) {
    	$problem = TRUE;
    	echo '<p class="false">' . $lang['enter_search_term'] . '!</p>
    	      <p>[ <a href="blog_search.php">' . $lang['go_to_search'] . '</a> ]</p>';
    	      }
    	
        	if(!$problem) {
        	
        	$text = htmlentities($_POST['search']);
        	
        	$query = "SELECT * FROM blog WHERE title LIKE '%$text%' OR post LIKE '%$text%' OR author LIKE '%$text%'";
        	$result = mysql_query($query) OR die(mysql_error());
        	
            $query2 = "SELECT blog_id, title, author, post, date FROM blog ORDER BY blog_id DESC LIMIT 10";
        	$result2 = mysql_query($query) OR die(mysql_error());
    	
    	if($result && $result2) {
    	
    	echo '<p><small><strong><u>' . mysql_num_rows($result) . '</u></strong> ' . $lang['search_results_found'] . ':</small></p>
    	      <table width="100%">';
    	
        while($row = mysql_fetch_assoc($result)) {
        	
            $view = 'blog_result.php?id=' . (int)$row['blog_id'];
        	
        	echo '<tr>
        	<td width="10%" valign="top"><span class="blue">ID:</span></td>
        	<td width="90%" valign="top">' . (int)$row['blog_id'] . '</td>
        	</tr>
        	<tr>
        	<td width="10%" valign="top"><span class="blue">' . $lang['author'] . ':</span></td>
        	<td width="90%" valign="top">' . htmlentities($row['author'], ENT_QUOTES) . '</td>
        	</tr>
        	<tr>
        	<td width="10%" valign="top"><span class="blue">' . $lang['title'] . ':</span></td>
        	<td width="90%" valign="top"><a href="' . $view . '">' . htmlentities($row['title'], ENT_QUOTES) . '</a></td>
        	</tr>
        	<tr>
        	<td width="10%" valign="top"><span class="blue">' . $lang['on_b'] . ':</span><br><br></td>
        	<td width="90%" valign="top"><em>';
            
            if($language == "de") {
                echo date('d.m.Y - H:i', strtotime($row['date']));
    
            }elseif($language == "en") {
                echo date('Y-m-d - H:i', strtotime($row['date'])); }
            
            echo '</em><br><br><br></td></tr>';
        	}
    	
            echo '</table>
                  <p>[ <a href="blog_search.php">' . $lang['search_again'] . '?</a> ]</p>';
    	
    		}else{
    	
    		echo '<p>' . $lang['no_search_results_found'] . ' - <a href="blog_search.php">' . $lang['search_again'] . '?</a></p>';
    		}
    	}
    	
        }else{
        
        echo '<table width="100%">
              <tr><td width="50%" align="left" valign="top"><form id="search" action="blog_search.php?search" method="post">
              <input type="text" name="search" size="30" class="fields">
              <input type="submit" name="submit" value="' . $lang['search'] . '" class="button"><br>
              <small>' . $lang['enter_search_term'] . '</small>
              </form><br></td>';
        
        $abfrage = mysql_query("SELECT blog_id FROM blog") OR die(mysql_error());
        $total = mysql_num_rows($abfrage);
        
        $abfrage2 = mysql_query("SELECT blog_id FROM comments") OR die(mysql_error());
        $total2 = mysql_num_rows($abfrage2); 
        
        echo '<td width="50%" align="right" valign="top"><u><strong>' . (int)$total . '</strong> ' . $lang['articles_with'] . ' <strong>' . (int)$total2 . '</strong> ' . $lang['comments_n'] . '</u></td></tr>
              </table>';
              }
    	
    	echo '<div class="spacer_div">&nbsp;</div>';

	   ?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community