Sya mempunyai masalah saat ingin membuat Paging pada Tabel Database yang berelasi. Dimana Pada Data No. 2 dan 3 juga keluar pada Page 2. Lebih jelasnya Silahkan Lihat Screen Shotnya di Bawah Ini:
http://perosot.in/images/list1.jpg
http://perosot.in/images/list2.jpg
Source:
<?php
//Koneksi Ke Database
include "config.php";
if(isset($_POST['submit'])){
$domain = $_POST['domain'];
$username = $_POST['username'];
$password = $_POST['password'];
$skin = $_POST['skin'];
$email = $_POST['email'];
$ftpdir = $_POST['ftpdir'];
$query = mysql_query("INSERT INTO cpanel (domain,username,password,skin,email) VALUES ('$domain','$username','$password','$skin','$email')");
$sql = "select max(id_cpanel) as last_id from cpanel limit 1";
$hasil = mysql_query($sql);
$row = mysql_fetch_array($hasil);
$lastId = $row['last_id'];
$sql = mysql_query("INSERT INTO directory (id_cpanel,ftpdir) VALUES ('$lastId','$ftpdir')");
if($query){
header ("Location:cpanel.php");
}else{
echo"Failed Add cPanel Account";
}
}
?>
<form action="" method="post">
<strong>Add cPanel Account</strong>
<table width="200" border="1">
<tr>
<td>Domain</td>
<td><input type='text' name='domain'></td>
</tr>
<tr>
<td>Username</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td>Skin</td>
<td><input type='text' name='skin' value='x3'></td>
</tr>
<tr>
<td>Email</td>
<td><input type='text' name='email'></td>
</tr>
<tr>
<td>Directory</td>
<td><input type='text' name='ftpdir'></td>
</tr>
<tr><td colspan='2' align='center'><input type='submit' name='submit' value='Submit'></td></tr>
</table>
</form>
<hr />
<style rel='stylesheet' type='text/css'>
th{
background:#1d87eb;
text-align: center;
font-type: bold;
border: 0px red;
}
tr{
background:#e6e6e6;
border: 0px;
}
</style>
<strong>List cPanel Account</strong>
<table>
<tr><th>No</th><th>Domain</th><th>Username</th><th>Password</th><th>Skin</th><th>Email</th><th>Directory</th><th>Option</th><th>Backup</th><th>DIR</th></tr>
<?php
$batas=5;
$halaman=$_GET['halaman'];
if(empty($halaman))
{
$posisi=0;
$halaman=1;
}
else
{
$posisi = ($halaman-1);
}
$query = mysql_query("SELECT * FROM cpanel t1, directory t2 WHERE t1.id_cpanel=t2.id_cpanel limit $posisi,$batas");
$no=$posisi+1;
while($data = mysql_fetch_array($query)){
echo"
<td>$no</td>
<td>$data[domain]</td>
<td>$data[username]</td>
<td>$data[password]</td>
<td>$data[skin]</td>
<td>$data[email]</td>
<td>$data[ftpdir]</td>
<td>
<INPUT TYPE='BUTTON' VALUE='Edit' ONCLICK=window.location.href='cpaneledit.php?id_cpanel=$data[id_cpanel]'> <INPUT TYPE='BUTTON' VALUE='Del' ONCLICK=window.location.href='cpaneldel.php?id_cpanel=$data[id_cpanel]'>
</td>
<td><INPUT TYPE='BUTTON' VALUE='Backup' ONCLICK=window.location.href='backup.php?id_cpanel=$data[id_cpanel]'></td>
<td><INPUT TYPE='BUTTON' VALUE='Create' ONCLICK=window.location.href='ftpaccess.php?id_cpanel=$data[id_cpanel]'></td></tr>
";
$no++;
}
echo "</table><br>";
$file="paging.php";
$tampil2="select * from cpanel t1, directory t2";
$hasil2=mysql_query($tampil2);
$jmlhalaman=ceil($hasil2/$batas);
//link ke halaman sebelumnya (previous)
if($halaman > 1)
{
$previous=$halaman-1;
echo "<A HREF=$file?halaman=1><< First</A> |
<A HREF=$file?halaman=$previous>< Previous</A> | ";
}
else
{
echo "<< First | < Previous | ";
}
$angka=($halaman > 3 ? " ... " : " ");
for($i=$halaman-2;$i<$halaman;$i++)
{
if ($i < 1)
continue;
$angka .= "<a href=$file?halaman=$i>$i</A> ";
}
$angka .= " <b>$halaman</b> ";
for($i=$halaman+1;$i<($halaman+3);$i++)
{
if ($i > $jmlhalaman)
break;
$angka .= "<a href=$file?halaman=$i>$i</A> ";
}
$angka .= ($halaman+2<$jmlhalaman ? " ...
<a href=$file?halaman=$jmlhalaman>$jmlhalaman</A> " : " ");
echo "$angka";
//link kehalaman berikutnya (Next)
if($halaman < $jmlhalaman)
{
$next=$halaman+1;
echo " | <A HREF=$file?halaman=$next>Next ></A> |
<A HREF=$file?halaman=$jmlhalaman>Last >></A> ";
}
else
{
echo " | Next > | Last >>";
}
?>
Mohon Bantuannya