Code: <?php //This code will obtain the required page number from the $_GET array. Note that if it is not present it will default to 1.
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
} // if
//This code will count how many rows will satisfy the current query.
$query ="SELECT * FROM `photos` WHERE `thumb_id` = '3'";
$result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
//This code uses the values in $rows_per_page and $numrows in order to identify the number of the last page.
$rows_per_page = 3;
$lastpage = ceil($numrows/$rows_per_page);
//This code checks that the value of $pageno is an integer between 1 and $lastpage.
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
$pageno = $lastpage;
} // if
if ($pageno < 1) {
$pageno = 1;
} // if
//This code will construct the LIMIT clause for the sql SELECT statement.
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
//Now we can issue the database qery and process the result.
$sql="SELECT * FROM `photos` WHERE `thumb_id` = '3'";
$res = mysql_query($sql) or die(mysql_error());
echo "<table>";
$i = 0;
while($row = mysql_fetch_assoc($res)){
$i++;
if ($i % 3 == 0)
echo '<tr>';
echo "<td> <img src="http://www.runningprofiles.com/members/include/myimages/thumbs/" . $row['picurl'] . "" /></a><br /> </td>";
if ($i % 3 == 0)
echo '</tr>';
if( $i == 9 ) break;
}
echo "</table>";
//... process contents of $result ...
//Finally we must construct the hyperlinks which will allow the user to select other pages. We will start with the links for any previous pages.
if ($pageno == 1) {
echo " FIRST PREV ";
} else {
echo " <a href='http://www.runningprofiles.com/members/index.php?page=album&pageno=1'>FIRST</a> ";
$prevpage = $pageno-1;
echo " <a href='http://www.runningprofiles.com/members/index.php?page=album&pageno=$prevpage'>PREV</a> ";
} // if
//Next we inform the user of his current position in the sequence of available pages.
echo " ( Page $pageno of $lastpage ) ";
//This code will provide the links for any following pages.
if ($pageno == $lastpage) {
echo " NEXT LAST ";
} else {
$nextpage = $pageno+1;
echo " <a href='http://www.runningprofiles.com/members/index.php?page=album&pageno=$nextpage'>NEXT</a> ";
echo " <a href='http://www.runningprofiles.com/members/index.php?page=album&pageno=$lastpage'>LAST</a> ";
} // if
?>
Im alittle confused by my pageinated results... i only have 2 images... and for some reason its repeated these images over 11 pages... how comes?
Format String help
I have a textbox where a person enters an application number. the application number is 10 characters in length:ex: 000012345A0256775434My clients only want to enter in the numbers without the
Date Question
I'm using the TIMESTAMP() function within mysql to set the date/time for certain events. However, how would I go about formatting the output? For example it would display "2009-11-30
How To Make More Than One Redirection with PHP on the same page?
Hey im trying to do a direction page where it open differently link direction pages every time somebody enter it.. like this for example any good hint on how to do this?<?phpheader(
Problem in back link
I have page where i have given javascript back link but when i click on it browser give a messageWebpage has expired
What's wrong with my code
sobbing for many days, still don't know why please Help. Why my page isn't posted correctly. In a nutshell, I have two pages, 1) is just a form another contains php with answer and if and else
how to get different value in second view of webdynpro?
hello guys,
Matchcode in ALV change header column
Hello everyone,
SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is significal for e.g Plan cost is 112 million where as budget is 136 million. In this situation what will
cPanel API
Hi Guys,Need a little guidance. I'm trying to get my script to communicate with cPanel (or WHM) to show certain statistics, for example, how much space/bandwidth has been used.I have been reading
Error Messaging not working
I changed the way my form tells the user of an error. But I can't seem to get it to work properly. Any help would be great. Thanks.Code: // IF NO errors process form if ($error == "")