Ok I went this way and it worked, but now have another issue.
If I have 50 pages, it will show 1,2,3,4,5,6,7 and so on...
How can I make this so that it only shows something like this...
Prev 123 Next and of course if I click on 3 then next page would show Prev 456 Next
I just can have it show all of those page numbers, that would look pretty gross.
SO if anyone can help, that would be great..
if(!isset($_SESSION['loggedin'])) {
header('Location: ../index.php?error=1');
exit();
} else {
$query="select zipcode from profile where username='$loggedin'";
$result = mysql_query($query);
while ($myrow = mysql_fetch_array($result)) {
$zipcode=$myrow["zipcode"];
}
$query="select * from login where user='$loggedin'";
$result = mysql_query($query);
while ($myrow = mysql_fetch_array($result)) {
$uid=$myrow["id"];
$email=$myrow["email"];
$firstname=$myrow["firstname"];
$lastname=$myrow["lastname"];
}
include("../tpl/clientsheader.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 = 2;//Sets the limit of results to display in each page
$start = ($num-1)*$limit;
$start = round($start,0);//rounds the result
$query = "SELECT * FROM profile where dsex='$dsex' order by id ASC LIMIT $start, $limit";
$result = mysql_query($query);
/*
While will repeat this query and mysql_fect_array allow me array the content
*/
echo "<center>Here are the results:<center><br><br>";
echo "<table border=\"0\" width=\"100%\" bordercolor=\"\#0000CD\" background=\"../images/bar_1.gif\">
<tr>
<td height=30><font face=Verdana color=ffffff size=3></font></td>
</tr>
</table>";
while($row2 = mysql_fetch_array($result))
{
$dsex = $row2["dsex"];
$height = $row2["height"];
include("height.php");
echo "<table border=\"0\" width=\"100%\">
<tr>
<td>
<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"\#0000CD\" border=\"1\">
<tr>
<td>
<table border=\"1\" width=\"100%\">
<tr>
<td width=\"200\"><center>
<a href=\"javascript:PopupPic('$picture')\"><img alt=\"My Picture\" src=\"$picture\" border=\"0\" width=\"100\" height=\"100\"></a><BR><img alt=\"Click My Picture\" src=\"../images/clickmypicture.gif\" border=\"0\" width=\"120\" height=\"33\"></center></td>
<td>
Sex = $dsex<BR>
</td>
</tr>
</table>
</td>
</tr>
<tr> <td bgcolor='#COCOCO'>";
include("distantbetween.php");
echo "</td></tr>
</table>
</td>
</tr>
</table><BR>"; };
$totalpages = mysql_num_rows(mysql_query("SELECT * FROM profile where dsex='$dsex'"));//Get the total number of results
$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=?num=$page&dsex=$dsex>[$page] </a>";//it echoes the url to the page
}
$c = $c+1;
}
echo "<br>".$totalpages." Pages in total.";//echoes the total pages
}