Location: PHPKode > projects > OneBlog > oneblog/index.php
<?php include('design/header.php'); ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50%" align="left"><?php
	
	include('data/config.php');

	if(isset($_POST['submit'])) {
	$problem = FALSE;
	
	if(empty($_POST['search'])) {
	$problem = TRUE;
	
	echo '<p>Geben Sie einen Suchbegriff ein - <a href="' . $index . '">Nochmal suchen?</a></p>';
	}
	
	if(!$problem) {
	$text = $_POST['search'];
	
	$query = "SELECT * FROM blog WHERE title LIKE '%$text%' OR post LIKE '%$text%' OR author LIKE '%$text%'";
	$result = mysql_query($query);
	$query2 = "SELECT blog_id, title, author, post, date FROM blog ORDER BY blog_id DESC LIMIT 10";
	$result2 = mysql_query($query);
	
	if($result && $result2) {
	echo '<p><small>Es wurden <strong><u>' . mysql_num_rows($result) . '</u></strong> Treffer gefunden:</small></p><br />';
	echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	
	while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
	$view = 'result.php?id=' . $row['blog_id'];

	echo '<tr>
			<td width="12%"><span class="blue">ID:</span></td>
			<td width="88%">' . htmlentities($row['blog_id']) . '</td>
		  </tr>
		  <tr>
			<td width="12%"><span class="blue">Autor:</span></td>
			<td width="88%">' . htmlentities($row['author'], ENT_QUOTES) . '</td>
		  </tr>
		  <tr>
			<td width="12%"><span class="blue">Titel:</span></td>
			<td width="88%"><a href="' . $view . '">' . htmlentities($row['title'], ENT_QUOTES) . '</a></td>
		  </tr>
		  <tr>
		  	<td><span class="blue">Am:</span></td>
		  	<td>' . date('d.m.Y - H:i', strtotime($row['date'])) . ' Uhr</td>
		  </tr>';
		  }
	
	echo '</table>';
	echo '<p><a href="' . $index . '">Nochmal suchen?</a></p>';
	
	}else{
	
	echo '<p>Keine Suchergebnisse gefunden - <a href="' . $index . '">Nochmal suchen?</a></p>';
		}
	}
	
	}else{
	
	echo '<form id="search" action="' . $index . '?search" method="post">
		  <input type="text" name="search" size="30" class="textfield" /> <input type="submit" name="submit" value="Suchen" class="textfield" />
		  </form>';
		  }

	?></td>
    <td width="50%" align="right" valign="bottom"><?php
	$abfrage = mysql_query("SELECT blog_id FROM blog"); 
	$total = mysql_num_rows($abfrage); 
	echo '<u>' . $total . ' Beitr&auml;ge vorhanden</u>';
	?></td>
  </tr>
  <tr>
	<td colspan="2"><br /></td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><?php

	$pfad = $_SERVER["PHP_SELF"];
	$query = mysql_query("SELECT blog_id FROM blog");
	$total = mysql_num_rows($query);
	$seiten = ceil($total / $datensaetze_pro_blog);

	if(empty($_GET['page'])){
	    $page = 1;
	}elseif($_GET['page'] <= 0 || $_GET['page'] > $seiten){
	    $page = 1;
	}else{
	    $page = mysql_real_escape_string($_GET['page']);
	}
	$links = array();
	if(($page - $p) < 1){ $davor = $page - 1;  }else { $davor = $p; }            
	if(($page + $p) > $seiten){ $danach = $seiten - $page; }else{ $danach = $p; }    
	$off = ($page - $davor);
	if ($page- $davor > 1){
	    $first = 1;
	       $links[] = "<a href=\"$pfad?page=$first\" title=\"Zur ersten Seite springen\">&laquo; Erste ...</a>\n";      
	}      
	if($page != 1){
	    $prev = $page-1;
	    $links[] = "<a href=\"$pfad?page=$prev\" title=\"Eine Seite zurueck blaettern\"> &laquo;</a>\n";     
	}   
	for($i = $off; $i <= ($page + $danach); $i++){
	  if ($i != $page){
	        $links[] = "<a href=\"$pfad?page=$i\">$i</a>\n";
	  }elseif($i == $seiten) {
	        $links[] = "<span class=\"current_main\">[ $i ]</span>\n";  
	  }elseif($i == $page){
	        $links[] = "<span class=\"current_main\">[ $i ]</span>\n";
	  }
	}                
	if($page != $seiten){
	    $next = $page+1;
	    $links[] = "<a href=\"$pfad?page=$next\" title=\"Eine Seite weiter blaettern\"> &raquo;</a>\n";
	}    
	if($seiten - $page - $p > 0 ){
	    $last = $seiten; 
	    $links[] = "<a href=\"$pfad?page=$last\" title=\"Zur letzten Seite springen\">... Letzte &raquo;</a>\n";
	}
	$start = ($page-1) * $datensaetze_pro_blog;
	$link_string = implode(" ", $links);
	
	$query = "SELECT * FROM blog ORDER BY date DESC LIMIT $start,$datensaetze_pro_blog";
	$result = mysql_query($query);
	
	if($result) {
	while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
	
	include_once('data/bbcode.php');
	
	echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
		   <tr>
			<td colspan="2"><h1>' . htmlentities($row['title'], ENT_QUOTES) . '</h1></td>
		   </tr>
		   <tr>
			<td width="70%" align="left">Von: <a href="mailto:' . $webmaster . '">' . htmlentities($row['author'], ENT_QUOTES) . '</a></td>
			<td width="30%" align="right">' . date('d.m.Y - H:i', strtotime($row['date'])) . ' Uhr</td>
		   </tr>
		   <tr>
			<td colspan="2"><div id="line">&nbsp;</div></td>
		   </tr>
		   <tr>
			<td colspan="2"><p>' . parseBBCode2HTML(nl2br(stripslashes($row['post']))) . '</p></td>
		   </tr>
		   <tr>
			<td width="70%" align="left"><a href="comments.php?id=' . $row['blog_id'] . '">Kommentare lesen</a> | 
			<a href="comments.php?id=' . $row['blog_id'] . '#comment">Kommentar schreiben</a></td>
			<td width="30%" align="right"><a href="' . $index . '#top"><img src="design/top_small.png" alt="Rauf" border="0" /></a> 
			<a href="rss.php" target="_blank"><img src="design/rss_small.png" alt="RSS Feeds" border="0" /></a></td>
		   </tr>
		   <tr>
			<td colspan="2"><br /></td>
		   </tr>
		</table>';
		}
	
	}else{
	echo '<p>Es sind noch keine Blog Beitr&auml;ge vorhanden!</p>';
	}
	
	echo '<br />';
	echo '<span class="pages_main">Seite ' . $page . ' von ' . $seiten . '</span>';
	echo $link_string;
	echo '<p> </p>';

	?></td>
  </tr>
</table>
<?php mysql_close($db); ?>
<?php include('design/footer.php'); ?>
Return current item: OneBlog