Here is what i have you may need to change it but this is what i got and feel free to change it the way you want it to work aswell.
Here is what i have
PHP Code:
$cid=($_GET['cid']);
if($_GET['cid'])
{
$cQuery="SELECT * FROM gallery WHERE cid='$cid'";
$result=mysqli_query($con,$cQuery);
if(!$result)
{
echo "Error:".mysqli_error($con);
}
else
{
$count=$result->num_rows;
if($count>0)
{
while($data=$result->fetch_assoc())
{
$cid=$data['cid'];
$alt=$data['alt'];
$description=$data['description'];
$imagethumbnail=$data['imagethumbnail'];
}
}
else
{
echo "<br/>There is no Gallery Informartion Found<br/>";
}
}
}?><form method="post" action="">
<input type="hidden" name="cid" value="<?php $cid ?>"></form>
<?php
$num = $_GET['num'];//Get the numeration of the page
if(empty($num)){//if the numeration is empty
$num = 1;//the numeration is 1
};
$limit = 3;//Sets the limit of results to display in each page, change if you want.
/*
The query will start selecting the numeration, for example 2, less 1, that would be 1
* the limits of results to show per page, 2 in this case so it would be 1*2 = 2, it will
start from 2 ;) if the limit would be 5 and the numeration would be 3 if would be (3-1)*5 = 10
*/
$start = ($num-1)*$limit;
$start = round($start,0);//rounds the result
/*
This query will select the contrene FROM the start and with a limit of 2, in this case,
because the variable $limit is 2
You can add a WHERE something= '$something' for example, or delete the ORDER by `id`, or change it,
etc
*/
$query = "SELECT * FROM gallery where cid='$cid' ORDER by `id` LIMIT $start, $limit";
$result = mysqli_query($con,$query);//now it makes the query and names it as result
/*
While will repeat this query and mysql_fect_array allow me array the content
*/
echo "<table>";
while ($data = mysqli_fetch_array($result)){
echo "<tr><td><a href=\"showart.php?id=".$data['id']."\"><img src=gallery/".$data['imagethumbnail']." width=\"100px\" height=\"100px\" alt=".$data['alt']."></a></td><td>".$data['description']."</td></tr><br/>";//Echoes the content
};
echo "</table>";
$totalpages = mysqli_num_rows(mysqli_query($con,"SELECT * from gallery where cid='$cid'"));//Get the total number of results
/*
Total resutls/ the limit, in this example is 2, so if there are 10 total result and the limit is 2
there will be 5 pages.
*/
$totalpages = $totalpages / $limit;
$totalpages = round($totalpages,0);
$c = 0;//The variable c is 0
echo "<br>";//make a <br> to separate the results from the [1][2]...
while($c<$totalpages){//while c is < than the total pages
$page = $c + 1;//sets the variable $page as 0 + 1 = 1
if($_GET['num']==$page){//Gets the number of the page and if its the same that the page
echo "[$page] ";//its only echoes the page, not the url to this page
}else{//else
echo "<a href=?cid=".$cid."&num=$page>[$page] </a>";//it echoes the url to the page
}
$c = $c+1;
}
echo "<br>".$totalpages." Pages in total.";//echoes the total pages
Bookmarks