Kamis, 27 Januari 2011

php code

<?php require_once('koneksi.php');
include (
'config.php'); mysql_select_db($database_db, $con_db);
    
$query = "SELECT * FROM guestbook ORDER BY id DESC";
    
$hasil = mysql_query($query, $con_db) or die(mysql_error());
    
$row_count = mysql_num_rows($hasil);
    
$page_row = 3;
    
$start = $_GET['start'];
    
$start = ($start == '') ? '0' : $start; 
    if (
$start >= $row_count)
    {
        
$start = 0;
        
$prev = 0;
        
$next = $page_row;
    } elseif (
$start >= 0)
    {
           
$start = $start;
        
$prev = $start - $page_row;
        
$next = $start + $page_row;
    } else {
        
$start = 0;
        
$prev = 0;
        
$next = $page_row;
    }
    
$query = "SELECT * FROM guestbook limit $start, $page_row";
    
$hasil = mysql_query($query, $con_db) or die(mysql_error());
    
$row=mysql_fetch_row($hasil);
        
while(
$data = mysql_fetch_array($hasil))
{
$komentar = $data['komentar'];

include (
'smiley.php');
echo "<table>";
echo 
"<tr><td>Judul</td><td> :</td><td> ".$data['judul']."</td></tr>";
echo 
"<tr><td>Nama</td><td> : </td><td> ".$data['nama']."</td></tr>";
echo 
"<tr><td>Komentar</td><td> : </td><td>".$komentar."</td></tr>";
echo 
"<img src='outimages/" .$data['gambar'] . "' align='left' height='75'>"; 
echo 
"</table><hr>"; 

}
while (
$row=mysql_fetch_row($hasil));
        
$num = $start;
        while (
$row_hasil = mysql_fetch_row($hasil)){
                    
            echo ++
$num." <b>".$row_hasil[1]."</b> ";
            echo 
"(".$row_hasil[3].")<br>";
            echo 
"".$row_hasil[2]."<br><br>";
        }
        
?>         <table border="0">
        <tr>
            <td><a href="comments_page.php?start=<?php echo $pref?>">Pref</a></td>
            <?php
            
for($i = 0; $i < (round($row_count / $page_row)); $i++)
                echo 
"<td><a href=\"comments_page.php?start=".($i * $page_row)."\">".($i  + 1)."</a></td>"; ?>             <td><a href="comments_page.php?start=<?php echo $next?>">Next</a></td>
        </tr>
        </table>

Tidak ada komentar:

Posting Komentar