davelf
08-09-2010, 11:05 AM
Hi, thx for viewing this.
problem:
i want to display my data in database like this one:
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3465&stc=1&d=1281351318
i used this script now:
<?php
include("admin/connect.php");
$dataPerPage = 2;
if(isset($_GET['page']))
{
$noPage = $_GET['page'];
}
else $noPage = 1;
$offset = ($noPage - 1) * $dataPerPage;
$sql = "SELECT * FROM product_book LIMIT $offset, $dataPerPage";
$result = mysql_query($sql) or die('Error');
$rs = mysql_query($sql);
while(
$fetch= mysql_fetch_array($rs)){
?>
<tr>
<td width="400px;">
<?php
$pecah = explode("more", $fetch['content']);
$excerpt = $pecah[0];
?>
<div class="fontContent news" align="justify"> <?=$excerpt?><br />
<a href="pBooks.php?id=<?=$fetch[0]?>">read more . . .</a>
</div>
<br /><br />
</td>
</tr>
<?php
}
$query = "SELECT COUNT(*) AS jumData FROM product_book";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$jumData = $data['jumData'];
$jumPage = ceil($jumData/$dataPerPage);
?>
<div class="num">
<?php
if ($noPage > 1) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'><< Prev</a>";
for($page = 1; $page <= $jumPage; $page++)
{
if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
{
if (($showPage == 1) && ($page != 2)) echo "...";
if (($showPage != ($jumPage - 1)) && ($page == $jumPage)) echo "...";
if ($page == $noPage) echo " <b>".$page."</b> ";
else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
$showPage = $page;
}
}
if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'>Next >></a>";
?>
the code that i used show up like this:
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3466&stc=1&d=1281351458
it's show only in a single coloum.
So how to make it happen?
thx in advanced....
this is a direct link to my project:
http://imaxxo.net/rotkan/listBooks.php
problem:
i want to display my data in database like this one:
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3465&stc=1&d=1281351318
i used this script now:
<?php
include("admin/connect.php");
$dataPerPage = 2;
if(isset($_GET['page']))
{
$noPage = $_GET['page'];
}
else $noPage = 1;
$offset = ($noPage - 1) * $dataPerPage;
$sql = "SELECT * FROM product_book LIMIT $offset, $dataPerPage";
$result = mysql_query($sql) or die('Error');
$rs = mysql_query($sql);
while(
$fetch= mysql_fetch_array($rs)){
?>
<tr>
<td width="400px;">
<?php
$pecah = explode("more", $fetch['content']);
$excerpt = $pecah[0];
?>
<div class="fontContent news" align="justify"> <?=$excerpt?><br />
<a href="pBooks.php?id=<?=$fetch[0]?>">read more . . .</a>
</div>
<br /><br />
</td>
</tr>
<?php
}
$query = "SELECT COUNT(*) AS jumData FROM product_book";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$jumData = $data['jumData'];
$jumPage = ceil($jumData/$dataPerPage);
?>
<div class="num">
<?php
if ($noPage > 1) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'><< Prev</a>";
for($page = 1; $page <= $jumPage; $page++)
{
if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
{
if (($showPage == 1) && ($page != 2)) echo "...";
if (($showPage != ($jumPage - 1)) && ($page == $jumPage)) echo "...";
if ($page == $noPage) echo " <b>".$page."</b> ";
else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
$showPage = $page;
}
}
if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'>Next >></a>";
?>
the code that i used show up like this:
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3466&stc=1&d=1281351458
it's show only in a single coloum.
So how to make it happen?
thx in advanced....
this is a direct link to my project:
http://imaxxo.net/rotkan/listBooks.php