hi everybody
i got this page form some template that shows items in the page with pagination system but i want to keep this method without any pagination i dont want to spilit number of items i just wanna see all of the items that it read from db in the page without any pagination system . please help me, here is the code of page
Also i need every 4 item in 1 row as this template but to show all of the items from db .

<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
<?php 
include "../../db.php";
?>
<?php
error_reporting(0);
//Rows
$imgRow = '<tr>';
$idRow = '<tr>';
$nn=10; //Number of items, we split this later
$s=mysql_query("SELECT * FROM `products`");
$c=mysql_num_rows($s);
if($c%$nn==0){
    $cc=$c/$nn; 
}else{
    $cc=$c/$nn+1;   
}
//$cc : Number of pages
$ss=@$_REQUEST['ss']; //Start position (eg: 6)
$other_tables = "";
if($ss=="" || $ss==null){
    $ss = 0; //Set to zero because it is incremented later
}
//Pages
echo "<table border=\"0\" align=\"center\" style=\"text-align:center;\">";
$sql=mysql_query("SELECT * FROM `products` ORDER BY `id` DESC LIMIT $ss,$nn");
$inc = 0;
while($r=mysql_fetch_array($sql)){
    $key=$r['id'];
    $id=$r['name'];  
    $img=$r['pic1'];
    if($inc == 0){
        $imgRow .= "<tr>";
        $idRow .= "<tr>";
    }
    $imgRow .= "<td title=\"مشاهده جزئیات محصول\"><a href=\"showproducts1-details.php?id=$key\" target=\"_self\" ><img src=\"../admin/products/productimages1/$img\" width=\"139\" height=\"122\" border=\"1\" /></a></td>";
    $idRow .= "<td><a href=\"showproducts1-details.php?id=$key\">$id</a></td>";
    ++$inc;
    if($inc == 5 || $inc == 12 || $inc == mysql_num_rows($sql)){
        //Display Table
        echo $imgRow."</tr>";
        echo $idRow."</tr>";
        echo "</table>";
        echo "<br>";echo "<br>";echo "<br>";
        //To remove extra table
        if(mysql_num_rows($sql) <= 5){
            $inc = 11;
        }
        //Reset
        if($inc == 5){
            echo "<table border=\"0\" align=\"center\" style=\"text-align:center;\">";
            $imgRow = "<tr>";
            $idRow = "<tr>";
        }
    }
}
echo "</table>";
echo "<br>";
?>  </td>
  </tr>
</table>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
<?php
$j=0;
echo"تعداد صفحات : ";
for($i=1;$i<=$cc;$i++){
    echo"<a href=\"showproducts1-1.php?ss=$j\">$i</a>";
    echo"|";
    $j=$j+$nn; 
}
?>
</td>
  </tr>
</table>

Recommended Answers

All 5 Replies

Member Avatar for diafol

Yuck! All that mixing of html and php is bad for your health. If I were you I'd drop the thing and start from scratch. This is not a good template.

Just help me with this ...

Member Avatar for diafol

Thanks for the downvote, but it remains a poor script. I was trying to tell you that it would take more effort to clean it up than to create a new one. I'm sorry if you're looking for somebody to do all the work for you, but that's not the aim of this forum. It seems that you've lifted this script from somewhere and now you want somebody to clean it up. If this isn't the case, I apologise. How about you try to strip out the php from all that html and then strip out the pagination stuff. 20 minutes work max?

i try many ways to do this is my project
and i dont have any time to discuss please if u can do it for me
i just want to show in each row 4 items without pagination just this

here is the simple form of code
i want to show all of the db data in the page
in each row 4 items then ++row (another row with 4 items) and so on ... just this

<?php
$sql=mysql_query("SELECT * FROM `products` where tf=1 and star='7' ORDER BY `id` DESC");
$inc = 0;
while($r=mysql_fetch_array($sql)){

    $id=$r['id'];
    ?>
<div style="width:152px; height:205px;">

<?php echo $id; ?>
</div>
<?php } ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.