<?php
include('../../include/database.php');
$photo_name = 'Photo1';
$gender = 'Male';
$ethnicity = 'Caucasian (White)';
// ***MY PROBLEM because I'm not using a (&_Get['']; the page count doesn't work how can I fix this? I would also like to have this to have 4 rows and 6 columns!! Right now this script prints out all of the data in one row****
if(!isset($GET['page'])){
$page = 1;
} else {
$page = $GET['page'];
}
// Define the number of results per page
$max_results = 4;
// Figure out the limit for the query based
// on the current page number.
$from = (($page $max_results) - $max_results);
$sql = mysql_query("SELECT FROM table WHERE photo_name = ('$photo_name') AND gender = ('$gender') ORDER BY ethnicity = ('$ethnicity') DESC ");
if ($row = mysql_fetch_array($sql)) {
do {
$path = $row["path"];
$mem_id = $row["mem_id"];
$ethnicity = $row["ethnicity"];
?>
<table width="144" border="0" bgcolor="#ECE9D8">
<tr>
<td width="138" height="157" align="center" valign="middle"><table width="130" height="148" border="0" background="../../clipart/nophoto.jpg">
<tr>
<td width="124" height="144" align="center" valign="middle"><img src="http://www.mysite.com/member_photos/<?php echo $row["path"]; ?>" alt="gallery" /></td>
</tr>
</table></td>
</tr>
</table>
<?php
} while($row = mysql_fetch_array($sql));
} else {print "Sorry, no records were found!";}
?>
<?php
{
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM table WHERE photo_name = ('$photo_name') AND gender = ('$gender') ORDER BY ethnicity = ('$ethnicity') DESC"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$prev&photo_name=$photo_name&gender=$genderðnicity=$ethnicity\">Previous</a> ";
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next&photo_name=$photo_name&gender=$genderðnicity=$ethnicity\">Next</a>";
}
echo "</center>";
}
?>