Viper Creations
Comeback Contest
Check out our forums for the an explosive comeback contest. We are giving away everything from iPods to Visual Studio. more...
»User: »Password:   Remember Me? 
Posted:  27 Dec 2006 04:59
Hi i just saw your pagination tutoral but i am still having some issue of intergreating it into my homemade Gallery for a start i cant seem to get the Pagination System to fit with my gallery system

and i having problems of showing 3 per page of the cid which is category id and its not showing the next,previous,first page buttons.

Code:


<form method="post" action="">
<input name="cid" type="hidden" value="<? echo $cid?>">
</form>
<?php
            include("dbconnect.php");
            $gQuery="SELECT * FROM gallery WHERE cid='$cid'";
            $rs=mysqli_query($con,$gQuery);
            if(!$rs)
            {
                $dbError="Error:Failed to executing query".mysqli_error($con);
            }
            else
            {
                $count=$rs->num_rows;
                if($count>0)
                {
                    print_r($data);
                    $data=$rs->fetch_assoc();
                    $imagethumbnail=$data['imagethumbnail'];
                }
                else
                {
                    print_r($data);
                    echo "<br/>Gallery Information Cannot be Found<br/>";
                }
                echo $cid;
    include("dbconnect.php");
     $max = 3;
     $p=$_GET['p'];
     if(empty($p))
     {
      $p=1;
     }
     $limits=($p-1) *$max;
     {
         $cid=$_GET['cid'];
        $dQuery="select * from gallery where cid='$cid'";
        echo $dQuery;
        $rs=mysqli_query($con,$dQuery);
        if(!$rs)
        {
            echo "Error:".mysqli_error($con);
        }
        while($data=mysqli_fetch_assoc($rs))
        {
                     $imagethumbnail=$data['imagethumbnail'];
                    $description=$data['description'];
                    echo "<tr><td><img src=gallery/".$imagethumbnail." width=\"100px\
                    \" height=\"100px\">
                    </td><td>".$description."</td>";
        }
        //else
        {
            $rQuery="select * from gallery limit".$limits.",".$max.")";
            $rs=mysqli_query($con,$rQuery);
            if(!$rs)
            {
                echo "Error:".mysqli_error($con);
            }
            else
            {
                $uQuery="select Count(id) as id from gallery";
                echo $uQuery;
                $totalres=mysqli_query($con,$uQuery);
                $totalpage=ceil($totalres/$max);
                echo "<table>";
                while($r=mysqli_fetch_array($uQuery))
                {
                     $imagethumbnail=$data['imagethumbnail'];
                    $description=$data['description'];
                    echo "<tr><td><img src=gallery/".$imagethumbnail." width=\"100px\
                    \" height=\"100px\">
                    </td><td>".$description."</td>";
                    echo "<td><a href='pages.php?cid=$cid'>$imagethumbnail</a></td><td>View Art</td></tr>";
                }
                echo "</tr></table>";
                for($i=1; $i<=$totalpages; $i++)
                {
                    echo "<a href='pages.php?p=$i'>$i</a>|";
                }   
            }
        }   
     }
    }
?>


Thats my Code what am i doing wrong?
Posted:  28 Dec 2006 16:46
Sry for the delay, william232.

our PHP coder is currently on vacation, but as soon as he is back i'll inform him of this problem..

in the meantime im sure someone else would LOVE to help you.

Right, guys?
__________________
http://i42.photobucket.com/albums/e336/arunkurian92/halocopy.gif
Posted:  28 Dec 2006 18:59
Hey there william

The thing is I took the easy way out and just decided not to include the next, previous, and first & last page links

this code should work:

Code:

     $max = 3;
     $p=$_GET['p'];
     if(empty($p))
     {
      $p=1;
     }
     $limits=($p-1) *$max;
     {
         $cid=$_GET['cid'];
        $dQuery="select * from gallery where cid='$cid'";
        echo $dQuery;
        $rs=mysqli_query($con,$dQuery);
        if(!$rs)
        {
            echo "Error:".mysqli_error($con);
        }
        while($data=mysqli_fetch_assoc($rs))
        {
                     $imagethumbnail=$data['imagethumbnail'];
                    $description=$data['description'];
                    echo "<tr><td><img src=gallery/".$imagethumbnail." width=\"100px\
                    \" height=\"100px\">
                    </td><td>".$description."</td>";
        }
        //else
        {
            $rQuery="select * from gallery limit".$limits.",".$max."";
            $rs=mysqli_query($con,$rQuery);
            if(!$rs)
            {
                echo "Error:".mysqli_error($con);
            }
            else
            {
                $uQuery="select Count(id) as id from gallery";
                echo $uQuery;
                $totalres=mysqli_query($con,$uQuery);
                $totalpage=ceil($totalres/$max);
                echo "<table>";
                while($r=mysqli_fetch_array($uQuery))
                {
                     $imagethumbnail=$data['imagethumbnail'];
                    $description=$data['description'];
                    echo "<tr><td><img src=gallery/".$imagethumbnail." width=\"100px\
                    \" height=\"100px\">
                    </td><td>".$description."</td>";
                    echo "<td><a href='pages.php?cid=$cid'>$imagethumbnail</a></td><td>View Art</td></tr>";
                }
$previous = $p-1;
$next=$p+1;
$lastpage = $totalpages;

                echo "</tr></table>";
                for($i=1; $i<=$totalpages; $i++)
                {
                    echo "<a href='pages.php?p=1'>First Page</a>|<a href='pages.php?p=$previous'>Previous</a>|<a href='pages.php?p=$i'>$i</a>|<a href='pages.php=$next'>Next</a>|<a href='pages.php?p=$lastpage'>Last Page</a>";
                }   
            }
        }   
     }
    }
?>


Tell me if that works or not!
__________________
http://www.vipercreations.com/images/banner/result.gif