PHP - Instagram Api Pagination
I am trying to use Cosenary's Instagram Class which is located at..
https://github.com/c...stagram-PHP-API Specifically, I am trying to do Pagination with a Tag Search. I want it to loop the process until it reach's yesterday's posts. I will run this script daily. <?php /** * Instagram PHP API * * @link https://github.com/cosenary/Instagram-PHP-API * @author Christian Metz * @since 01.10.2013 */ require '../dbinclude.php'; require 'Instagram.php'; use MetzWeb\Instagram\Instagram; // initialize class $instagram = new Instagram(array( 'apiKey' => '***************', 'apiSecret' => '***************', 'apiCallback' => '*************' // must point to success.php )); ?> <?php $i = 0; $imagecount = 0; do { $i++; echo "Pagination restart"; $photos = $instagram->getTagMedia('kittens'); $result = $instagram->pagination($photos); foreach($result->data as $post) { $image = mysqli_real_escape_string($toolconn, $post->images->low_resolution->url); $caption = mysqli_real_escape_string($toolconn, $post->caption->text); $author = mysqli_real_escape_string($toolconn, $post->user->username); $created = mysqli_real_escape_string($toolconn, $post->created_time); $created = date("Y-m-d H:i:s", $created); $compare = substr($created, 0, 10); $twodays = date("Y-m-d",strtotime("-2 days")); $link = $post->link; // echo $twodays . "<br>"; echo $compare . "<Br>"; $sql = "INSERT INTO userfeeds (link, thumbnail, created_at, caption, author) VALUES ('$link', '$image', '$created', '$caption', '$author')"; // $exec = mysqli_query($toolconn, $sql); echo $sql . "<br>"; echo "Created; " . $compare . "<BR>"; echo "Comparison; " . $twodays . "</br><hr>"; } } while ($compare != $twodays); ?> I have been trying to do this for about three weeks now. For some reason, my loop doesnt work. Help! In the documentation it says the following.. Each endpoint has a maximum range of results, so increasing the limit parameter above the limit won't help (e.g. getUserMedia() has a limit of 90). That's the point where the "pagination" feature comes into play. Simply pass an object into the pagination() method and receive your next dataset: <?php $photos = $instagram->getTagMedia('kitten'); $result = $instagram->pagination($photos); ?> Iteration with do-while loop.Basically my end goal is to make sure everyday I didnt miss a post.. I have been trying to work on this for literally three weeks and I have gotten nowhere Similar TutorialsHi guys, got some questions about the Instagram real-time api. first let me tell you what I want to do. I'd like to run a daemon process with a socket connection or something of the like to the Instagram API to get a constant feed of photos with a certain tag. We estimate it to be a large amount of data at a particular time (thus why we want to go Real-time). This process will parse the feed and store it into a mongodb database. Secondly, for the front end, I'd like to display all new, live photos in real-time, possible with ajax or some form of checking on a set interval. Problem being, I can't find anyone doing this with php. All of the resources I have seen use Node.js and Tornado. Has anyone done this with PHP or know of a good Real-time API demonstration/tutorial to get me started? Here's the documentation... http://instagr.am/developer/realtime/ any help would be greatly appreciated! thanks! The problem here is my pagination. It works for the most part. The only part that does NOT work is that when I go to a page OTHER THAN the first page it WILL NOT allow me to click on the edit link and go to the edit matchtype form. It allows me to on the first page of list but not for any after that. Code: [Select] <?php error_reporting(E_ALL); // Include the database page include ('../inc/dbconfig.php'); $query = "SELECT CONCAT_WS(' ', handlers.firstName, handlers.lastName) AS name, DATE_FORMAT(matchTypes.dateCreated, '%M %d, %Y') AS dateCreated, matchTypes.ID, matchTypes.matchType FROM matchTypes INNER JOIN handlers ON matchTypes.creatorID = handlers.ID WHERE matchTypes.enabled = '0' ORDER BY matchTypes.matchType"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); $itemsPerPage = 10; $pages = ceil( $rows / $itemsPerPage ); ?> <script> $(document).ready(function() { $('a', $('div#addform')).click(function() { $('#innerContent').load('forms/' + $(this).attr('id') + '.php?case=addnew'); }); // Add the table sorter and table paginator plugins $('#matchTypesPageList').tablesorter() .tablesorterPager({ container: $( '#matchTypesPageList .paginate' ), cssPageLinks: 'a.pageLink' }); $('.edit').click(function(){ var matchTypeID = $(this).attr('rel'); $('#innerContent').load('forms/matchtype.php?id=' + matchTypeID + '&case=edit'); }); $('.delete').click(function(){ var matchTypeID = $(this).attr('rel'); var dataString = 'matchTypeID=' + matchTypeID + '&deleteMatchType=True'; $.ajax({ type: "POST", url: "processes/matchtype.php", data: dataString, }); var table = $(this).closest("table"); if (table.find("tr").length == 3) { table.remove(); } else { $(this).closest("tr").remove(); } }); }); </script> <!-- Title --> <div id="title" class="b2"> <h2>Match Types</h2> <!-- TitleActions --> <div id="titleActions"> <!-- ListSearch --> <div class="listSearch actionBlock"> <div class="search"> <label for="search">Recherche</label> <input type="text" name="search" id="search" class="text" /> </div> <div class="submit"> <button type="submit" id="search-button" class="button"><strong><img src="img/icons/search_48.png" alt="comments" class="icon "/></strong></button> </div> </div> <!-- /ListSearch --> <!-- newPost --> <div id="addform" class="newPost actionBlock"> <a href="#" id="matchtype" class="button"><strong>Add New Match Type<img src="img/icons/add_48.png" alt="new post" class="icon "/></strong></a> </div> <!-- /newPost --> </div> <!-- /TitleActions --> </div> <!-- Title --> <!-- Inner Content --> <div id="innerContent"> <!-- ListHeader --> <div id="listHeader"> <p class="listInfos"> You have <?php echo $rows; ?> match types. </p> </div> <!-- /ListHeader --> <!-- ListTable --> <?php if ($rows > 0) { ?> <table cellspacing="0" class="listTable" id="matchTypesPageList"> <!-- Thead --> <thead> <tr> <th class="first"><div><a href="#" title="Match Type Name">Match Type Name</a></div></th> <th><a href="#" title="Creator">Creator</a></th> <th><a href="#" title="Date Created">Date Created</a></th> <th class="last">Edit/Delete</th> </tr> </thead> <!-- /Thead --> <!-- Tfoot --> <tfoot> <tr> <td colspan="4"> <div class="inner"> <div class="paginate"> <?php if( $pages > 1 ) { for( $i = 1; $i <= $pages; $i++ ) { echo '<span style="padding-left: 5px; padding-right: 5px;"><a class="pageLink" href="#">' . $i . '</a></span>'; } } ?> </div> </div> </td> </tr> </tfoot> <!-- /Tfoot --> <!-- Tbody --> <tbody> <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td>' . $row['matchType'] . '</td> <td>' . $row['name'] . '</td> <td>' . $row['dateCreated'] . '</td> <td style="text-align:center;"><img src="img/notepad.png" class="edit" rel="' . $row['ID'] . '"/><img src="img/Delete-icon.png" class="delete" rel="' . $row['ID'] . '"/></td> </tr>'; } ?> </tbody> <!-- /Tbody --> </table> <?php } ?> <!-- /ListTable --> </div> <!-- /Inner Content --> My php/mysql book doesn't cover pagination so I've been searching the web for a simple pagination script that I can learn from. I got the following one working at http://www.phpsimplicity.com/tips.php?id=1 but it's just showing the next and prev links... no results on the pages and you can click on the next link forever when there's only 11 records in the table I queried. How can I display results on each page and have the info append to the next page? This is the second example I've tried and none seem to explain this part? Using the tutorial from php freaks i was able to get pagination working on my site. How ever there are a few changes id like to make. I would like to have it listed in 2 columns. The other problem that I'm having is when i attempt to add class="nav" to the next page link i get an error. Can a class be used in a php echo? Here's what I have. Code: [Select] <?php session_start(); $rank=$_SESSION['rank']; $loggedinusername=$_SESSION['loggedinusername']; $loggedinuseremail=$_SESSION['loggedinuseremail']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Drink To The Credits</title> <link href="mainstyle.css" rel="stylesheet" type="text/css" /> </head> <body class="background"> <div id="header"> <?php include_once"header.php" ?></div> <div id="content"> <?php include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or trigger_error("SQL", E_USER_ERROR); $sql = "SELECT COUNT(*) FROM movies WHERE type LIKE 'movie'"; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; $rowsperpage = 15; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT title FROM movies ORDER BY title LIMIT $offset, $rowsperpage" ; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); while ($list = mysql_fetch_assoc($result)) { ?> <tr> <td> <a class="nav" href=/rules.php?title=<?php echo urlencode($list['title']); ?>><?php echo $list['title']; ?></a> <br /> <?php } $range = 3; if ($currentpage > 1) { echo " <a href='<?php {$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // built with a tutorial from php freaks ?> </div> <div id="sidecontent"><?php include_once"newmovies.php" ?></div> <div id="footer"> <?php include_once"footer.php" ?></div> </body> </html> Thank you in advance Hi guys, I have a question about pagination. It's not really about the coding side so I'm really sorry if this is the wrong section! Ok my question is, does pagination actually create multiple pages? I'm really new to PHP and I'm just reading through different things and tutorials to try and figure it out if you will. So does it create new pages? From my understanding it simply changes a variable to a page number and uses that page number (and simple matH) to figure out what rows to show. If this is the case, how do people use pagination to create links such as http://example.com/imnooby/page-1 http://example.com/imnooby/page-2 http://example.com/imnooby/page-3 Surely if this was all just one page, it would just be http://example.com/imnooby/page and the variable would change depending on the button, but the same page would be reloaded? This is the part that's really bugging me and any explanation would really help. Hello, I am trying to incorporate pagination to only show 20 rows per page but instead the links work but shows all rows on all pages. Link to see: http://webjax.99k.org/ Full Code: Code: [Select] <?php include ("./header.php"); //PAGINATION $sql = "SELECT COUNT(*) FROM servers"; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; //END PAGINATION //======================================================================== Commands If (isSet($_GET['sort'])) { $sortby = $_GET['sort']; If ($sortby=='name' || $sortby=='ip' || $sortby=='votes' || $sortby=='username') { If ($sortby=='name') { $options = "<option value='./index.php?sort=name' selected='selected'>Name</option> <option value='./index.php?sort=ip'>IP Address</option> <option value='./index.php?sort=votes'>Rank</option> <option value='./index.php?sort=username'>Owner</option>"; } If ($sortby=='ip') { $options = "<option value='./index.php?sort=name'>Name</option> <option value='./index.php?sort=ip' selected='selected'>IP Address</option> <option value='./index.php?sort=votes'>Rank</option> <option value='./index.php?sort=username'>Owner</option>"; } If ($sortby=='votes') { $options = "<option value='./index.php?sort=name'>Name</option> <option value='./index.php?sort=ip'>IP Address</option> <option value='./index.php?sort=votes' selected='selected'>Rank</option> <option value='./index.php?sort=username'>Owner</option>"; } If ($sortby=='username') { $options = "<option value='./index.php?sort=name'>Name</option> <option value='./index.php?sort=ip'>IP Address</option> <option value='./index.php?sort=votes'>Rank</option> <option value='./index.php?sort=username' selected='selected'>Owner</option>"; } } else { $sortby = "votes"; $options = "<option value='./index.php?sort=name'>Name</option> <option value='./index.php?sort=ip'>IP Address</option> <option value='./index.php?sort=votes' selected='selected'>Rank</option> <option value='./index.php?sort=username'>Owner</option>"; } } else { $sortby = "votes"; $options = "<option value='./index.php?sort=name'>Name</option> <option value='./index.php?sort=ip'>IP Address</option> <option value='./index.php?sort=votes' selected='selected'>Rank</option> <option value='./index.php?sort=username'>Owner</option>"; } If ($_GET['act']=='see' && isSet($_GET['id'])) { //=================================================================== XSS protection $sid = str_replace("/", "", $_GET['id']); $sid = str_replace(Chr(92), "", $sid); $sid = str_replace("'", "", $sid); $sid = str_replace('"', "", $sid); $sid = str_replace("<", "", $sid); $sid = str_replace(">", "", $sid); $sid = str_replace("-", "", $sid); $sid = str_replace("union", "", $sid); $sid = str_replace("information_schema", "", $sid); $sid = strtolower(trim($sid)); //=================================================================== XSS protection $result = mysql_query("SELECT * FROM servers WHERE id='$sid'") or die (mysql_error()); $nr = mysql_num_rows($result); If ($nr<='0') { $exist = "No"; } else { $exist = "Yes"; while($row = mysql_fetch_array($result)) { If ($row['name']=='') { $servername = "<img src='./banners/" .$row['banner']. "' style='width:468px;height:60px' title='Server details'>"; } else { $servername = $row['name']; } $did = $row['id']; $dname = $row['name']; $dbanner = $row['banner']; $dip = $row['ip']; $ddescription = $row['description']; $dwebsite = $row['website']; $dcountry = $row['country']; $dsponsored = $row['sponsored']; $dvotes = $row['votes']; $mineq = $row['mineq']; $dusername = $row['username']; $ddate = $row['date']; If ($dusername==$username) { $me = "Yes"; } else { $me = "No"; } If ($mineq=='Yes') { If (!$dip=='') { include ("./minequery.class.php"); $mine = array((Minequery::query($dip))); $donlinep = $mine["0"]["playerCount"]; If ($donlinep>0) { for ($i = 0; $i <= $donlinep; $i++) { $playername = $mine["0"]["playerList"][$i]; If (!$playername=='') { $donline .= $playername. ", "; } } $donline = left($donline, strlen($donline)-2); } } else { $donline = "<i>n/a</i>"; } } else { $donline = "<i>n/a</i>"; } } } } If ($_GET['act']=='' || $_GET['act']=='sponsored' || $_GET['act']=='myservers') { $result = mysql_query("SELECT * FROM servers ORDER BY votes DESC") or die (mysql_error()); while($rk_list[] = mysql_fetch_array($result)); If (isSet($username) && $_GET['act']=='myservers') { $result = mysql_query("SELECT * FROM servers WHERE username='$username' ORDER BY id DESC") or die (mysql_error()); } else { If ($_GET['act']=='sponsored') { $result = mysql_query("SELECT * FROM servers WHERE sponsored='Yes' ORDER BY id DESC") or die (mysql_error()); } else { If (isSet($_GET['country'])) { $result = mysql_query("SELECT * FROM servers WHERE country='$_GET[country]' ORDER BY votes DESC") or die (mysql_error()); } else { $result = mysql_query("SELECT * FROM servers ORDER BY $sortby DESC") or die (mysql_error()); } } } $nr = mysql_num_rows($result); If ($nr<='0') { $serverslist = "<tr><td align='center' colspan='6'>There are no servers added yet !</td></tr>"; } else { include ("./minequery.class.php"); $rank = "0"; while($row = mysql_fetch_array($result)){ $data[] = $row; } foreach ($data as $row) { $rank = ($rank + 1); If ($row['banner']=='') { $servername = $row['name']; } else { $servername = "<img src='" .$row['banner']. "' style='width:400px;height:60px' title='Server details'>"; } If ($row['sponsored']=='Yes') { $star = "style='background:url(./images/star.png);background-repeat:no-repeat;'"; } else { $star = ""; } If ($row['mineq']=='Yes') { If (!$row['ip']=='') { $mine = array((Minequery::query($row['ip']))); $onlinep = $mine["0"]["playerCount"]; } else { $onlinep = "<i>n/a</i>"; } } else { $onlinep = "<i>n/a</i>"; } $country = "./flags/" .$row['country']. ".png"; $serverslist .= "<tr><td align='center'>" .(array_search($row, $rk_list) + 1). "</td><td align='center'><a href='./index.php?country=" .$row['country']. "'><img src='" .$country. "' title='" .$row['country']. "' style='width:32px;height:32px;'></a></td><td align='center' valign='middle' style='height:60px;'><a class='nav' href='./index.php?act=see&id=" .$row['id']. "' title='Server details'>" .$servername. "</a></td><td align='center' " .$star. ">" .$row['ip']. "</td><td align='center'>" .$onlinep. "</td><td align='center'>" .$row['votes']. "</td></tr>"; //$serverslist .= "<tr><td align='center'>" .$row['id']. "</td><td align='center' valign='middle' style='height:60px;'><a class='nav' href='./index.php?act=see&id=" .$row['id']. "' title='Server details'>" .$servername. "</a></td><td align='center'><img src='./flags/" .$row['country']. ".ico' title='" .$row['country']. "'> " .$row['ip']. "</td><td align='center'>" .$row['votes']. "</td><td align='center'>" .$row['date']. "</td></tr>"; //$serverslist .= "<tr><td align='center'>" .$row['id']. "</td><td align='center'>" .$servername. "</td><td align='center'>" .country_flag($row['ip']). " " .$row['ip']. "</td><td align='center'>" .$row['votes']. "</td></tr>"; } } } /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ //======================================================================== Strings $countries = "<option>Afghanistan</option> <option>Albania</option> <option>Algeria</option> <option>Andorra</option> <option>Angola</option> <option>Antigua and Barbuda</option> <option>Argentina</option> <option>Armenia</option> <option>Aruba</option> <option>Australia</option> <option>Austria</option> <option>Azerbaijan</option> <option>Bahamas, The</option> <option>Bahrain</option> <option>Bangladesh</option> <option>Barbados</option> <option>Belarus</option> <option>Belgium</option> <option>Belize</option> <option>Benin</option> <option>Bermuda</option> <option>Bhutan</option> <option>Bolivia</option> <option>Bosnia and Herzegovina</option> <option>Botswana</option> <option>Brazil</option> <option>Brunei</option> <option>Bulgaria</option> <option>Burkina Faso</option> <option>Burma</option> <option>Burundi</option> <option>Cambodia</option> <option>Cameroon</option> <option>Canada</option> <option>Cape Verde</option> <option>Cayman Islands</option> <option>Central African Republic</option> <option>Chad</option> <option>Chile</option> <option>China</option> <option>Colombia</option> <option>Comoros</option> <option>Congo, Democratic Republic of the</option> <option>Congo, Republic of the</option> <option>Costa Rica</option> <option>Cote d'Ivoire</option> <option>Croatia</option> <option>Cuba</option> <option>Curacao</option> <option>Cyprus</option> <option>Czech Republic</option> <option>Denmark</option> <option>Djibouti</option> <option>Dominica</option> <option>Dominican Republic</option> <option>Ecuador</option> <option>Egypt</option> <option>El Salvador</option> <option>Equatorial Guinea</option> <option>Eritrea</option> <option>Estonia</option> <option>Ethiopia</option> <option>Fiji</option> <option>Finland</option> <option>France</option> <option>Gabon</option> <option>Gambia</option> <option>Georgia</option> <option>Germany</option> <option>Ghana</option> <option>Greece</option> <option>Grenada</option> <option>Guatemala</option> <option>Guinea</option> <option>Guinea-Bissau</option> <option>Guyana</option> <option>Haiti</option> <option>Holy See</option> <option>Honduras</option> <option>Hong Kong</option> <option>Hungary</option> <option>Iceland</option> <option>India</option> <option>Indonesia</option> <option>Iran</option> <option>Iraq</option> <option>Ireland</option> <option>Israel</option> <option>Italy</option> <option>Jamaica</option> <option>Japan</option> <option>Jordan</option> <option>Kazakhstan</option> <option>Kenya</option> <option>Kiribati</option> <option>Kosovo</option> <option>Kuwait</option> <option>Kyrgyzstan</option> <option>Laos</option> <option>Latvia</option> <option>Lebanon</option> <option>Lesotho</option> <option>Liberia</option> <option>Libya</option> <option>Liechtenstein</option> <option>Lithuania</option> <option>Luxembourg</option> <option>Macau</option> <option>Macedonia</option> <option>Madagascar</option> <option>Malawi</option> <option>Malaysia</option> <option>Maldives</option> <option>Mali</option> <option>Malta</option> <option>Marshall Islands</option> <option>Mauritania</option> <option>Mauritius</option> <option>Mexico</option> <option>Micronesia</option> <option>Moldova</option> <option>Monaco</option> <option>Mongolia</option> <option>Montenegro</option> <option>Morocco</option> <option>Mozambique</option> <option>Namibia</option> <option>Nauru</option> <option>Nepal</option> <option>Netherlands</option> <option>Netherlands Antilles</option> <option>New Zealand</option> <option>Nicaragua</option> <option>Niger</option> <option>Nigeria</option> <option>North Korea</option> <option>Norway</option> <option>Oman</option> <option>Pakistan</option> <option>Palau</option> <option>Panama</option> <option>Papua New Guinea</option> <option>Paraguay</option> <option>Peru</option> <option>Philippines</option> <option>Poland</option> <option>Portugal</option> <option>Qatar</option> <option>Romania</option> <option>Russia</option> <option>Rwanda</option> <option>Saint Kitts and Nevis</option> <option>Saint Lucia</option> <option>Saint Vincent and the Grenadines</option> <option>Samoa</option> <option>San Marino</option> <option>Sao Tome and Principe</option> <option>Saudi Arabia</option> <option>Senegal</option> <option>Serbia</option> <option>Seychelles</option> <option>Sierra Leone</option> <option>Singapore</option> <option>Slovakia</option> <option>Slovenia</option> <option>Solomon Islands</option> <option>Somalia</option> <option>South Africa</option> <option>South Korea</option> <option>South Sudan</option> <option>Spain</option> <option>Sri Lanka</option> <option>Sudan</option> <option>Suriname</option> <option>Swaziland</option> <option>Sweden</option> <option>Switzerland</option> <option>Syria</option> <option>Taiwan</option> <option>Tajikistan</option> <option>Tanzania</option> <option>Thailand</option> <option>Timor-Leste</option> <option>Togo</option> <option>Tonga</option> <option>Trinidad and Tobago</option> <option>Tunisia</option> <option>Turkey</option> <option>Turkmenistan</option> <option>Tuvalu</option> <option>Uganda</option> <option>Ukraine</option> <option>United Arab Emirates</option> <option>United Kingdom</option> <option>Uruguay</option> <option>Uzbekistan</option> <option>Vanuatu</option> <option>Venezuela</option> <option>Vietnam</option> <option>Yemen</option> <option>Zambia</option> <option>Zimbabwe</option>"; $servers = "<table align='center' class='fancy' width='100%'> <tr><th align='left' colspan='6'>Servers list</th></tr> <tr><td align='left' colspan='3'>Servers : " .$nr. "</td><td align='right' colspan='3'>Arrange by : <select name='by' onChange=location.href=this.options[this.selectedIndex].value;>" .$options. "</select></td></tr> <tr><th align='center' width='1%'>#</th><th align='center' width='1%'>Country</th><th align='center' width='47%'>Name / Banner</th><th align='center' width='20%'>IP Address</th><th align='center' width='1%'>Players Online</th><th align='center' width='1%'>Votes</th></tr> " .$serverslist. " </table>"; $addsv = "<table align='center' class='fancy' width='100%'> <tr><th align='left' colspan='2'>Add server</th></tr> <tr><td align='left' width='100px'>Name :</td><td align='left'><input class='field' type='text' name='aname' style='width:100%;'></td></tr> <tr><td align='left'>Banner url :</td><td align='left'><input class='field' type='text' name='abanner' style='width:100%;'></td></tr> <tr><td align='left'>Description :</td><td align='left'><textarea class='textarea' name='adescription'></textarea></td></tr> <tr><td align='left'>IP Address :</td><td align='left'><input class='field' type='text' name='aip'></td></tr> <tr><td align='left'>Website :</td><td align='left'><input class='field' type='text' name='awebsite'></td></tr> <tr><td align='left'>Country :</td><td align='left'><select name='acountry'>" .$countries. "</select></td></tr> <tr><td align='left'>MineQuery :</td><td align='left'><select name='amine'><option selected='selected'>Yes</option><option>No</option></select></td></tr> <tr><td align='left'>Captcha :</td><td align='left'><img src='./captcha.php' title='Captcha'> <input class='field' type='text' name='captcha' style='width:100px;' maxlength='5'></td></tr> <tr><td> </td><td align='left'><input type='submit' name='aok' value='Add'></td></tr> </table>"; $login = "<table align='left' class='fancy' width='40%'> <tr><th align='left' colspan='2'>Login</th></tr> <tr><td align='left' width='30%'>Username :</td><td align='left'><input class='field' type='text' name='lname'></td></tr> <tr><td align='left'>Password :</td><td align='left'><input class='field' type='password' name='lpass'></td></tr> <tr><td> </td><td align='left'><input type='submit' name='lok' value='Login'></td></tr> </table>"; $register = "<table align='left' class='fancy' width='45%'> <tr><th align='left' colspan='2'>Register</th></tr> <tr><td align='left' width='30%'>Username :</td><td align='left'><input class='field' type='text' name='rname'> <font color='red'>*</font></td></tr> <tr><td align='left'>E-mail :</td><td align='left'><input class='field' type='text' name='rmail'> <font color='red'>*</font></td></tr> <tr><td align='left'>Password :</td><td align='left'><input class='field' type='password' name='rpass'> <font color='red'>*</font></td></tr> <tr><td align='left'>Re-Password :</td><td align='left'><input class='field' type='password' name='rrepass'> <font color='red'>*</font></td></tr> <tr><td> </td><td align='left'><input type='submit' name='rok' value='Register'></td></tr> </table>"; $settings = "<table align='left' class='g' width='80%'> <tr><th align='left' colspan='2'>Settings</th></tr> <tr><td width='50%' valign='top'> <table align='left' class='fancy' width='100%'> <tr><th align='left' colspan='2'>My account</th></tr> <tr><td align='left'>E-mail : </td><td align='left'>" .$uemail. "</td></tr> <tr><td align='left'>Servers : </td><td align='left'>" .$uservers. "</td></tr> <tr><td align='left'>Next vote : </td><td align='left'>" .$unextvoted. "</td></tr> <tr><td align='left'>Join date : </td><td align='left'>" .$udate. "</td></tr> </table> </td><td width='50%' valign='top'> <table align='left' class='fancy' width='100%'> <tr><th align='left' colspan='2'>Change password</th></tr> <tr><td align='left'>Current password : </td><td align='left'><input type='password' name='cpass'></td></tr> <tr><td align='left'>New password : </td><td align='left'><input type='password' name='cnpass'></td></tr> <tr><td align='left'>New re-password : </td><td align='left'><input type='password' name='cnrepass'></td></tr> <tr><td> </td><td align='left'><input type='submit' name='cok' value='Change'></td></tr> </table> </td></tr> </table>"; $f = fopen("./mine.txt", "r"); while ($line = fgets($f, 9999)) { $minetext .= $line. ""; } fclose($f); $minequery = "<table align='left' class='fancy' width='100%'> <tr><th align='left' colspan='2'>MineQuery</th></tr> <tr><td align='left'> " .$minetext. " </td></tr> </table>"; $f = fopen("./help.txt", "r"); while ($line = fgets($f, 9999)) { $helptext .= $line. ""; } fclose($f); $help = "<table align='left' class='fancy' width='100%'> <tr><th align='left' colspan='2'>Help</th></tr> <tr><td align='left'> " .$helptext. " </td></tr> </table>"; If ($me=='No') { If ($dname=='') { $dname = "<i>none</i>"; } If ($dbanner=='') { $dbanner = "<i>none</i>"; } else { $dbanner = "<img src='" .$dbanner. "' title='Banner' style='width:468px;height:60px'>"; } $details = "<table align='center' class='fancy' width='100%'> <tr><th align='left' colspan='2'>Server details</th></tr> <tr><td align='left' width='100px'>Name :</td><td align='left'>" .$dname. "</td></tr> <tr><td align='left'>Banner url :</td><td align='left'>" .$dbanner. "</td></tr> <tr><td align='left'>Description :</td><td align='left'>" .$ddescription. "</td></tr> <tr><td align='left'>Players online :</td><td align='left'>" .$donline. "</td></tr> <tr><td align='left'>IP Address :</td><td align='left'>" .$dip. "</td></tr> <tr><td align='left'>Website :</td><td align='left'>" .$dwebsite. "</td></tr> <tr><td align='left'>Sponsored :</td><td align='left'>" .$dsponsored. "</td></tr> <tr><td align='left'>Votes :</td><td align='left'>" .$dvotes. "</td></tr> <tr><td align='left'>Owner :</td><td align='left'>" .$dusername. "</td></tr> <tr><td align='left'>Added at :</td><td align='left'>" .$ddate. "</td></tr> <tr><td align='left'>Vote link :</td><td align='left'><a class='nav' href='" .$siteurl. "/vote.php?id=" .$did. "' title='Vote link'>" .$siteurl. "/vote.php?id=" .$did. "</td></tr> </table>"; } else { $details = "<table align='center' class='fancy' width='100%'> <tr><th align='left' colspan='2'>Server details</th></tr> <tr><td align='left' width='100px'>Name :</td><td align='left'><input class='field' type='text' name='nname' style='width:700px;' value='" .$dname. "'></td></tr> <tr><td align='left'>Banner url :</td><td align='left'><input class='field' type='text' name='nbanner' style='width:700px;' value='" .$dbanner. "'></td></tr> <tr><td align='left'>Description :</td><td align='left'><textarea class='textarea' name='ndescription'>" .$ddescription. "</textarea></td></tr> <tr><td align='left'>Players online :</td><td align='left'>" .$donline. "</td></tr> <tr><td align='left'>IP Address :</td><td align='left'><input class='field' type='text' name='nip' value='" .$dip. "'></td></tr> <tr><td align='left'>Website :</td><td align='left'><input class='field' type='text' name='nwebsite' value='" .$dwebsite. "'></td></tr> <tr><td align='left'>Vote link :</td><td align='left'><a class='nav' href='" .$siteurl. "/vote.php?id=" .$did. "' title='Vote link'>" .$siteurl. "/vote.php?id=" .$did. "</td></tr> <tr><td> </td><td align='left'><input type='submit' name='dok' value='Update'> <input type='submit' name='delok' value='Delete'></td></tr> </table>"; } //======================================================================== Display echo "<form method='post' action='" .curPageURL(). "' style='margin:0px;'>"; If ($sidebar=="Yes") { echo "<table align='center' width='100%'> <tr><td align='left' width='80%' valign='top'>"; } If ($_GET['act']=='add' || $_GET['act']=='see' || $_GET['act']=='login' || $_GET['act']=='register' || $_GET['act']=='settings' || $_GET['act']=='myservers' || $_GET['act']=='minequery' || $_GET['act']=='help') { If ($_GET['act']=='add') { If (!$_SESSION['user']=='') { echo $addsv; } else { echo $login; } } If ($_GET['act']=='login') { If ($_SESSION['user']=='') { echo $login; } else { echo $servers; } } If ($_GET['act']=='register') { If ($_SESSION['user']=='') { echo $register; } else { echo $servers; } } If ($_GET['act']=='see') { If ($exist=='Yes') { echo $details; } else { echo $servers; } } If ($_GET['act']=='settings') { If ($_SESSION['user']=='') { echo $login; } else { echo $settings; } } If ($_GET['act']=='myservers') { echo $servers; } If ($_GET['act']=='minequery') { echo $minequery; } If ($_GET['act']=='help') { echo $help; } } else { echo $servers; } If ($sidebar=="Yes") { echo "</td><td align='right' width='20%' valign='top'> <table align='center' width='100%' class='fancy'> " .$rsidead. " </table> </td></tr> </table>"; } echo "</form>"; include ("./footer.php"); ?> this is where I tried to put pagination in: Code: [Select] If ($_GET['act']=='' || $_GET['act']=='sponsored' || $_GET['act']=='myservers') { $result = mysql_query("SELECT * FROM servers ORDER BY votes DESC") or die (mysql_error()); while($rk_list[] = mysql_fetch_array($result)); If (isSet($username) && $_GET['act']=='myservers') { $result = mysql_query("SELECT * FROM servers WHERE username='$username' ORDER BY id DESC") or die (mysql_error()); } else { If ($_GET['act']=='sponsored') { $result = mysql_query("SELECT * FROM servers WHERE sponsored='Yes' ORDER BY id DESC") or die (mysql_error()); } else { If (isSet($_GET['country'])) { $result = mysql_query("SELECT * FROM servers WHERE country='$_GET[country]' ORDER BY votes DESC") or die (mysql_error()); } else { $result = mysql_query("SELECT * FROM servers ORDER BY $sortby DESC") or die (mysql_error()); } } } $nr = mysql_num_rows($result); If ($nr<='0') { $serverslist = "<tr><td align='center' colspan='6'>There are no servers added yet !</td></tr>"; } else { include ("./minequery.class.php"); $rank = "0"; while($row = mysql_fetch_array($result)){ $data[] = $row; } foreach ($data as $row) { $rank = ($rank + 1); If ($row['banner']=='') { $servername = $row['name']; } else { $servername = "<img src='" .$row['banner']. "' style='width:400px;height:60px' title='Server details'>"; } If ($row['sponsored']=='Yes') { $star = "style='background:url(./images/star.png);background-repeat:no-repeat;'"; } else { $star = ""; } If ($row['mineq']=='Yes') { If (!$row['ip']=='') { $mine = array((Minequery::query($row['ip']))); $onlinep = $mine["0"]["playerCount"]; } else { $onlinep = "<i>n/a</i>"; } } else { $onlinep = "<i>n/a</i>"; } $country = "./flags/" .$row['country']. ".png"; $serverslist .= "<tr><td align='center'>" .(array_search($row, $rk_list) + 1). "</td><td align='center'><a href='./index.php?country=" .$row['country']. "'><img src='" .$country. "' title='" .$row['country']. "' style='width:32px;height:32px;'></a></td><td align='center' valign='middle' style='height:60px;'><a class='nav' href='./index.php?act=see&id=" .$row['id']. "' title='Server details'>" .$servername. "</a></td><td align='center' " .$star. ">" .$row['ip']. "</td><td align='center'>" .$onlinep. "</td><td align='center'>" .$row['votes']. "</td></tr>"; //$serverslist .= "<tr><td align='center'>" .$row['id']. "</td><td align='center' valign='middle' style='height:60px;'><a class='nav' href='./index.php?act=see&id=" .$row['id']. "' title='Server details'>" .$servername. "</a></td><td align='center'><img src='./flags/" .$row['country']. ".ico' title='" .$row['country']. "'> " .$row['ip']. "</td><td align='center'>" .$row['votes']. "</td><td align='center'>" .$row['date']. "</td></tr>"; //$serverslist .= "<tr><td align='center'>" .$row['id']. "</td><td align='center'>" .$servername. "</td><td align='center'>" .country_flag($row['ip']). " " .$row['ip']. "</td><td align='center'>" .$row['votes']. "</td></tr>"; } } } /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='./{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ I'm not sure what im doing wrong can anyone help? Hi guy seems to be having bit of trouble with this it gets first id then go's to pot when i hit the number 2 and so on nothing is there any help would be great Code: [Select] <?php $per_page = 1; $query = mysql_query("SELECT COUNT('id') FROM product"); $pages = ceil(mysql_result($query, 0) / $per_page); $page = (isset($_GET['id']) AND (int)$_GET['id'] > 0) ? (int)$_GET['id'] : 1; $start = ($page - 1) * $per_page; ?> <?php if(isset($_GET['id'])){ $id = $_GET['id']; $query = mysql_query("SELECT * FROM product WHERE productMenu=" . mysql_real_escape_string((int)$id) . " LIMIT {$start}, {$per_page}")or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ ?> <div id="productHolder"> <div id="topprodlist"> <div id="prodName"><p>Product Name: <?php echo $row['productName']; ?></p></div> <div id="prodCode"><p>Code: <?php echo $row['code']; ?></p></div> <div id="prodSize"><p>Size: <?php echo $row['size']; ?></p></div> <div id="prodDiameter"><p>Diameter: <?php echo $row['diameter']; ?></p></div> </div> <div id="imageBox"><img src="prodimg/<?php echo $row['image']; ?>" width="100" height="100" alt="<?php echo $row['image']; ?>"></div> <div id="prodDescription"> <div id="descript"><h5>Description:</h5></div> <div id="prodTextBox"><p><?php echo $row['short']; ?></p> <a href="info.php?in=<?php echo $row['id']; ?> ">More Details:</a> </div> </div> <div id="clear"></div> </div> <?php }} ?> <?php if($pages >= 1){ for ($x=1; $x<=$pages; $x++){ echo "<a href=?id=$x> $x </a>"; } } ?> I need a little help trying to figure this out. I have a page that pulls up data, you can then click on one and go to a page with more detail. On this page you can use the PRrev & Next to go view another detail page on other data. My problem is if my 1st page has 6 sets of data on it but has a total of, say 50, you can only use the Prev & Next to view the 6. I want to be able to use the Prev & Next to go thru all 50. ie Page1 pulls this info data1 data2 data3 data4 data5 data6 < << 1 2 [3] 4 5 6 > >> Page2 Data 1 Lots of info about data 1 < Prev Next > You will only be able to view the 6 data sets in the table above, however there are 50 I want to be able to use the < Prev Next > to go to all of them Can someone help me with this? here is my code Page1 <?php session_start(); // session timing // set timeout period in seconds $inactive = 120; // check to see if $_SESSION['timeout'] is set if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; if($session_life > $inactive) { session_destroy(); } } $_SESSION['timeout'] = time(); // END session timing include('library/login.php'); login(); mysql_select_db('test'); // sets the sessions for all values $_SESSION=array_merge($_SESSION,$_POST); // echoing to verify $gender=$_SESSION[gender]; $genderPref=$_SESSION[genderPref]; echo "Chossen Gender".$_SESSION['gender']; echo "<br><Br>"; echo "GenderPref".$_SESSION['genderPref']; echo "<br><Br>"; // if the user has been timed out or not logged in if (!isset($_SESSION['clientID'])){ echo "You are not a register user - set this to a simple search form"; echo "<br><a href='form.php'>Form</a>"; } // user is logged in else { $clientID = $_SESSION['clientID']; $sql="SELECT * FROM user WHERE userID='$clientID'"; $result=mysql_query($sql); while ($r=mysql_fetch_array($result)) { $exp_date=$r["exp_date"]; $todays_date=date("Y-m-d"); } // verifies billing if ($exp_date >= $todays_date) { // billing is up to date $result = mysql_query("SELECT * FROM user WHERE gender='$gender'") or die(mysql_error()); // ------ Sets the display of data ------ $num_rows = mysql_num_rows($result); // number of rows to show per page $rowsperpage = 8; // find out total pages $totalpages = ceil($num_rows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; $result = mysql_query("SELECT * FROM user WHERE gender='$gender' LIMIT $offset, $rowsperpage")or die(mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows == 0){ echo "<div id='noResults'><span class='sorry'>Sorry</span>, no results found. <br> Please try again with broader search options.</div>"; } else { // format for search results $cells_wide = 2; echo " <table cellspacing='0' cellpadding='3' border='0' width='700'><tr> "; $c = 0; while ($r=mysql_fetch_array($result)) { $userID=$r["userID"]; $gender=$r["gender"]; $aUserIDs[] = $userID; if (0 < $c && 0 == $c % $cells_wide){ echo " </tr><tr> "; } echo " <td width=175> "; echo "<a href='profileSession.php?userID=$r[userID]'>$userID</a>, $gender</td>"; $c++; } // end of while echo " </tr>"; echo " </table> "; } // -------- BUILD THE PAGINATION LINKS -------------------------------- $_SESSION['userID']=$aUserIDs; $_SESSION['userID2']=$aUserIDs2; echo "<div id='navigation'>"; // range of num links to show $range = 3; // if not on page 1, show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>‹‹ </a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'> ‹ </a> "; } // END if ($currentpage > 1) // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($totalpages == 1) { echo ""; } else{ if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } // END if ($x == $currentpage) else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>$x</a> "; } // END else } // END else } // END if (($x > 0) && ($x <= $totalpages)) } // END for loop // if not on last page, show forward and last page links if ($totalpages == 0) { echo ""; } else{ if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'> › </a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>›› </a> "; } // END if ($currentpage != $totalpages) }// END else echo "<br>currentpage=$currentpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2"; $link='currentpage='; $link1='&gender='; $link2='&genderPref='; $link3='&ageMin='; $link4='&ageMax='; $link5='&year1='; $link6='&year2='; $total=$link.$currentpage.$link1.$genderPref.$link2.$gender.$link3.$ageMin.$link4.$ageMax.$link5.$year1.$link6.$year2; $_SESSION['pages']=$total; echo "<br>$total"; // -------- END PAGINATION -------------------------------------------- } // END if ($exp_date >= $todays_date) else { // billing has expired echo "Billing has expired<br>"; echo $_SESSION['clientID']; echo "<br><a href='session2.php'>Sesssion2</a>"; echo "<br><a href='form.php'>Form</a>"; } } // END valid session ?> Page2 <?php session_start(); // start up your PHP session! include('library/login.php'); login(); mysql_select_db('test'); $userID=$_GET["userID"]; $link=$_SESSION['pages']; // Sends back to display page echo "<a href='searchSession.php?$link' title='Back to Search'>Back to Search</a> "; // sets the Prev & Next $aUsers = isset($_SESSION['userID']) ? $_SESSION['userID'] : array(); $current = $userID; // Ok our current. $iCurKey = array_search($current, $aUsers); $prev = null; $next = null; if ($iCurKey !== false){ $prev = $iCurKey >= 1 ? $aUsers[$iCurKey - 1] : null; $next = $iCurKey < count($aUsers) - 1 ? $aUsers[$iCurKey + 1] : null; } // Lets do this simple. if ($prev !== null){ echo ' <A href="?userID=' . $prev . '">« Previous</A> '; } else{ echo " <span class='empty'>« Previous</span> "; } if ($next !== null){ echo '<A class=right href="?userID=' . $next . '">Next »</A> '; } else{ echo "<span class='empty'> Next »</span>"; } // END of the Prev & Next $result = mysql_query("SELECT userID, first_name, gender FROM user WHERE userID='$userID'") or die(mysql_error()); while ($r=mysql_fetch_array($result)){ $userID=$r["userID"]; $first_name=$r["first_name"]; $gender=$r["gender"]; } echo "<br>$userID, $first_name, $gender"; ?> I am trying to do my own pagination script to better learn php i do need some help.. First let me explain my goal, then show you the code I have which is not working. I have 5 blogs per page; I have at least 30 blogs in the database for testing purpose; I want the pagination to go as shown if you are first viewing the blog no page selected it will show [1] 2 3 4 5 ... Last Page if you for example choose page three it will show 1 2 [3] 4 5 ... Last Page Now what is happening when you click on page 5 or 6 it does First Page... 4 5 [6] When I would like it to show First Page... 2 3 4 5 [6] or 2 3 4 [5] 6 here is my code Code: [Select] <?php //if current page != 1 show first page link $Show .= ($this->CurPage != 1 ? "<a href=\"?module=blog&page=1\">First Page</a>... " : ""); //We need the number of start for the for statement //We need to check if the number of pages excedes three if it does then make the start minus 2 of the current page $Start = (($this->CurPage - 2) >= 1 ? $this->CurPage - 2 : 1); //We need the end page for the for statement $End = (($this->CurPage + 2) <= $this->NumOfPages ? $this->CurPage + 2 : $this->NumOfPages); //Run End Again to make sure $NewEnd = ($End <= 3 && $this->NumOfPages > 5 ? $End + 2 : $End); //Run Start again to make sure $NewStart = ($this->CurPage >= ($this->NumOfPages - 2) ? $Start - 2 : $Start); for ($i = $NewStart; $i <= $NewEnd; $i++) { $Show .= ($i == $this->CurPage ? "<a href=\"?module=blog&page={$i}\"><strong>[{$i}]</strong></a> " :"<a href=\"?module=blog&page={$i}\">{$i}</a> " ); } //If More than one page and you are not on the last page $Show .= ($this->CurPage != $this->NumOfPages && $this->NumOfPages > 1 ? " ...<a href=\"?module=blog&page={$this->NumOfPages}\">Last Page</a>" : ""); return $Show; ?> Hello! I have a database of small image / names that I want to pull into a 3 x 4 table. My current code works perfectly if I have 12 images or less, but I will have more than 12 images. Currently the code is set up to retrieve and display the images in a table, three per table row. I want it so that when it reaches the 4th row in a page it generates a link to another page that has the next 3 x 4 (12 total images) page. I tried to follow the code on http://www.phpfreaks.com/tutorial/basic-pagination, but after I get it to what I think it should be, my page is blank -- but not due to an error, it's just blank. My code so far is: <?php $username = "xxxx"; $password = "xxxxx"; $host = "localhost"; $database = "images"; $conn = mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error()); $db = mysql_select_db($database) or die("Can not select the database: ".mysql_error()); $sql = "SELECT * FROM block_work ORDER BY Name"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); header('Content-type: image/jpg'); $counter = 0; while ($row = mysql_fetch_array($result)) { if($counter==0) print "<tr align='center'>"; ++$counter; print "<td align='center' width='179' height='200'><img src='/management/show.php?id=" . $row['id'] . "&table=block_work' alt='" . $row['name'] . "' /><br/>"; print "<b>" . $row['name'] . "</b></td>"; if($counter==3) { $counter=0; print "</tr>"; }; }; while ($counter>0) { ++$counter; print " <td> </td>"; if($counter==3) { $counter=0; print "</tr>"; } } print "</table>"; mysql_close($con); ?> Thanks very much for any help! -Gerry Hi Guys, I tried to put pagination code into my search results but every time I get an ugly error. Can you guys help me please?I just want to put 5 results per page. Why does it have to be so complicated. I am just asking something very simple (Well, it shows that you don't know anything about php dude! ( I am just talking to myself)) <a href="search.php">Search</a><br> <br> <?php include("connect.php"); $first_name = "%" . $_POST["first_name"] . "%"; $last_name = "%" . $_POST["last_name"] . "%"; $age = "%" . $_POST["age"] . "%"; $query= "SELECT * FROM `contacts` WHERE `first_name` LIKE '$first_name' AND `last_name` LIKE '$last_name' AND `age` LIKE '$age' ORDER BY `contacts`.`first_name` ASC LIMIT 0, 30 "; $result = mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); if ($num > 0 ) { $i=0; while ($i < $num) { $first_name = mysql_result($result,$i,"first_name"); $last_name = mysql_result($result,$i,"last_name"); $age = mysql_result($result,$i,"age"); $id = mysql_result($result,$i,"id"); echo "<b>first name:</b> $first_name<br>"; echo "<b>last name:</b> $last_name<br>"; echo "<b>age:</b> $age<br>"; echo "<a href=\"update.php?id=$id\">Update</a> - <a href=\"delete.php?id=$id\">Delete</a>"; echo "<br><br>"; ++$i; } } else { echo "No Results"; }?> Is there a way of doing pagination other than going through the whole big file, like: Code: [Select] $limit = "LIMIT 0, 30"; if ($_GET['page'] == 2) { $limit = "LIMIT 30, 30"; } $sql = "SELECT * FROM table WHERE blah = 'blah' $limit"; $result = mysql_query($sql); But is there a way to do this without having to write an if statement for each page without getting to extensive? Thanks! Sorry to bug yalls with yet another problem, but I tried applying pagination to the page I use to display the news on my website, which is stored within mysql, and I'm having major issues. Here's the code below for both the pagination and getting the news out of the database to display. Not sure what's going on here. I tested the script and it does everything fine except it doesn't display the information stored within the database. Go here to see for yourself: http://www.djsmiley.net/index.php Code: [Select] <?php /* Place code to connect to your DB here. */ include('cms/news/dbconnect.php'); // include your code to connect to DB. $tbl_name="mynews"; //your table name // How many adjacent pages should be shown on each side? $adjacents = 3; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "index.php"; //your file name (the name of this file) $limit = 1; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT 10 FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\"><img class=\"fltlft2\" src=\"http://www.djsmiley.net/images/Icons/Arrows/Previous.png\" height=\"25\" width=\"25\"></a>"; else $pagination.= "<span class=\"disabled\"><img class=\"fltlft2\" src=\"http://www.djsmiley.net/images/Icons/Arrows/Previous.png\" height=\"25\" width=\"25\"></a></span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\"><img src=\"http://www.djsmiley.net/images/Icons/Arrows/Next.png\" height=\"25\" width=\"25\"></a>"; else $pagination.= "<span class=\"disabled\"><img src=\"http://www.djsmiley.net/images/Icons/Arrows/Next.png\" height=\"25\" width=\"25\"></span>"; $pagination.= "</div>\n"; } ?> <?php while($row = mysql_fetch_array($result)) { echo("<p class=NewsContainer><span class=NewsID>$type</span> <font size=5>$title</font><br><br> <em>posted by <strong>$user</strong> | added on $time</em><br><br> $message<br><br> <label class=fltlft2><img src=../images/Icons/Arrows/Right.png width=20 height=20/></label><a href=$url>Read more - $url</a> <div class=newsLikeShareRate> <table width=100% border=0> <tr> <td width=3% height=21><script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script> <fb:like href='$url' show_faces=true width=450 font=arial></fb:like> </td> <td width=65%><a name=fb_share id=fb_share4 type=icon_link share_url=$url>Share</a> <script src=http://static.ak.fbcdn.net/connect.php/js/FB.Share type=text/javascript></script></td> <td width=32%>Rate this article: </td> </tr> </table> </div></p><br><br>");// Your while loop here } ?> <?=$pagination?> I can't get my head around it, no matter how many tutorials I read.. So would anyone be able to put this code into a pagination of 3 per page? Many Thanks Code: [Select] <?php if(!$_GET['id']) { $query = "SELECT * FROM news where published = '1' ORDER by id DESC"; $result = mysql_query($query) or die(mysql_error()); $news = mysql_fetch_assoc($result); ?> <?php do { ?> <table width="590" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><h2><? echo $news['title']; ?></h2></td> </tr> <tr> <td width="398"><? echo $news['story']; ?></td> <td width="192"><img src="<? echo $news['image']; ?>" alt="<? echo $news['shortstory']; ?>" width="192" height="108" /></td> </tr> <tr> <td colspan="2"><i><br /> Posted by <? echo $news['author']; ?> on <? echo $news['date']; ?></i></td> </tr> </table><br /> <?php } while ($news = mysql_fetch_assoc($result)); } ?> Code: [Select] <?php $title="Search"; $metakeywords="search, find"; $metadescription="Search for your love!"; include ('header.php'); $getpage=clean_up($_GET['page']); $getpage = abs((int) ($getpage)); echo ' <table width="100%"><tr><td valign="top" class="content"> <form action="index.php?action=search" method="post"> <b>Seeking Gender</b> <select name="gender"> <option value="">Either</option> <option value="Male">Male</option> <option value="Female">Female</option> </select> <hr> <b>Smoke?</b> <select name="smoke"> <option value="">Doesn\'t matter</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> <hr> <b>Drink?</b> <select name="drink"> <option value="">Doesn\'t matter</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> <hr> <b>Body Type </b> <select name="bodytype"> <option value="">Doesn\'t matter</option> <option value="Slim / Slender">Slim / Slender</option> <option value="Athletic">Athletic</option> <option value="Average">Average</option> <option value="Some extra baggage">Some extra baggage</option> <option value="Body builder">Body builder</option> </select> </td><td valign="top" class="content"> <b>First Name</b> <input type="text" name="first" size="17"><br> <b>Last Name</b><input type="text" name="last" size="17"> <hr> <b>Sexual orientation</b> <select class="orientation" name="orientation"> <option value="">Any</option> <option value="Bi">Bi</option> <option value="Gay/Lesbian">Gay/Lesbian</option> <option value="Straight">Straight</option> </select> <hr> <b>Age Range</b> <select class="date" name="age_from">'; $years = range( 16, 100 ); foreach( $years as $v ) { echo "<option value=\"$v\">$v</option>\n"; } echo ' </select> to <select class="date" name="age_to">'; $yyears = range( 17, 100 ); foreach( $yyears as $v ) { echo "<option value=\"$v\">$v</option>\n"; } echo '</select> </td><td valign="top" class="content"> <b>Religion</b> <select name="religious"> <option value="">Any</option> <option value="Agnostic">Agnostic</option> <option value="Atheist">Atheist</option> <option value="Buddhist">Buddhist</option> <option value="Catholic">Catholic</option> <option value="Christian">Christian</option> <option value="Hindu">Hindu</option> <option value="Jewish">Jewish</option> <option value="Mormon">Mormon</option> <option value="Muslim">Muslim</option> <option value="Other">Other</option> <option value="Protestant">Protestant</option> <option value="Satanist">Satanist</option> <option value="Scientologist">Scientologist</option> <option value="Taoist">Taoist</option> <option value="Wiccan">Wiccan</option> </select> <hr> <b>Ethnicity</b> <select name="ethnicity"> <option value="">Any</option> <option value="Asian">Asian</option> <option value="Black / African descent">Black / African descent</option> <option value="East Indian">East Indian</option> <option value="Latino / Hispanic">Latino / Hispanic</option> <option value="Middle Eastern">Middle Eastern</option> <option value="Native American">Native American</option> <option value="Pacific Islander">Pacific Islander</option> <option value="White / Caucasian">White / Caucasian</option> <option value="Other">Other</option> </select> <hr> <b>Children</b> <select name="children"> <option value="">Doesn\'t matter</option> <option value="I don\'t want kids">I don\'t want kids</option> <option value="Love kids, but not for me">Love kids, but not for me</option> <option value="Undecided">Undecided</option> <option value="Someday">Someday</option> <option value="Expecting">Expecting</option> <option value="Proud parent">Proud parent</option> </select> <hr> <b>Education</b> <select name="education"> <option value="">Doesn\'t matter</option> <option value="High school">High school</option> <option value="Some college">Some college</option> <option value="In college">In college</option> <option value="College graduate">College graduate</option> <option value="Grad / professional school">Grad / professional school</option> <option value="Post grad">Post grad</option> </select> <br><input type="submit" name="submit" value="Search" /></form> </td></tr></table>'; if($_POST['submit'] || $_GET['page'] > "0"){ $first = clean_up($_POST['first']); $last = clean_up($_POST['last']); $smoke = clean_up($_POST['smoke']); $drink = clean_up($_POST['drink']); $gender = clean_up($_POST['gender']); $age_from = clean_up($_POST['age_from']); $age_to = clean_up($_POST['age_to']); $orientation = clean_up($_POST['orientation']); $religious = clean_up($_POST['religious']); $ethnicity = clean_up($_POST['ethnicity']); $bodytype = clean_up($_POST['bodytype']); $children = clean_up($_POST['children']); $education = clean_up($_POST['education']); if(!$_GET['page']){ if(!$first == ""){ setcookie("first", $first, time()+3600); } if(!$last == ""){ setcookie("last", $last, time()+3600); } if(!$smoke == ""){ setcookie("smoke", $smoke, time()+3600); } if(!$drink == ""){ setcookie("drink", $drink, time()+3600); } if(!$gender == ""){ setcookie("gender", $gender, time()+3600); } if(!$age_from == ""){ setcookie("age_from", "$age_from", time()+3600); } if(!$age_to == ""){ setcookie("age_to", "$age_to", time()+3600); } if(!$orientation == ""){ setcookie("orientation", $orientation, time()+3600); } if(!$religious == ""){ setcookie("religious", $religious, time()+3600); } if(!$ethnicity == ""){ setcookie("ethnicity", $ethnicity, time()+3600); } if(!$bodytype == ""){ setcookie("bodytype", $bodytype, time()+3600); } if(!$children == ""){ setcookie("children", $children, time()+3600); } if(!$education == ""){ setcookie("education", $education, time()+3600); } } $qquery = "SELECT `id`, `first`, `last`, `avatar`, `gender`, `about`, ( (DATE_FORMAT(CURDATE(),'%Y') - DATE_FORMAT(`bdate`, '%Y') ) - ( DATE_FORMAT(CURDATE(), '00-%m-%d') < DATE_FORMAT( `bdate`, '00-%m-%d')) ) AS age FROM `users` WHERE ( (DATE_FORMAT(CURDATE(),'%Y') - DATE_FORMAT(`bdate`, '%Y') ) - ( DATE_FORMAT(CURDATE(), '00-%m-%d') < DATE_FORMAT( `bdate`, '00-%m-%d')) ) BETWEEN $age_from AND $age_to"; // if any of the options that are stored in the `users` table are selected, add AND to the query string, //and store each needed part in an array, $users_criteria if( $gender != "" || $first != "" || $last != "" ) { $qquery .= ' AND '; $users_criteria = array(); if( !empty($gender) ) { $users_criteria[] = "`gender` = '$gender'"; } if( !empty($first) ) { $users_criteria[] = "`first` LIKE '%$first%'"; } if( !empty($last) ) { $users_criteria[] = "`last` LIKE '%$last%'"; } $qquery .= implode( ' AND ', $users_criteria ); // implode the array, separating each part with AND, and append to query string } // Same process as above, but for results that come from `questions` table if( $smoke != '' || $drink != '' || $orientation != '' || $religious != '' || $ethnicity != '' || $bodytype != '' ) { $qquery .= ' AND id IN( SELECT `userid` FROM `questions` WHERE '; $questions_criteria = array(); if( !empty($smoke) ) { $questions_criteria[] = "`smoke` = '$smoke'"; } if( !empty($drink) ) { $questions_criteria[] = "`drink` = '$drink'"; } if( !empty($orientation) ) { $questions_criteria[] = "`orientation` = '$orientation'"; } if( !empty($religious) ) { $questions_criteria[] = "`religious` = '$religious'"; } if( !empty($ethnicity) ) { $questions_criteria[] = "`ethnicity` = '$ethnicity'"; } if( !empty($bodytype) ) { $questions_criteria[] = "`body_type` = '$bodytype'"; } if( !empty($children) ) { $questions_criteria[] = "`children` = '$children'"; } if( !empty($education) ) { $questions_criteria[] = "`education` = '$education'"; } $qquery .= implode( ' AND ', $questions_criteria ); $qquery .= ' )'; } $total = mysql_num_rows(mysql_query($qquery)); $page_count = ceil($total / 2); $page = 1; if (isset($getpage) && $getpage >= 1 && $getpage <= $page_count) { $page = (int)$getpage; } $skip = ($page - 1) * 2; $query = "SELECT `id`, `first`, `last`, `avatar`, `gender`, `about`, ( (DATE_FORMAT(CURDATE(),'%Y') - DATE_FORMAT(`bdate`, '%Y') ) - ( DATE_FORMAT(CURDATE(), '00-%m-%d') < DATE_FORMAT( `bdate`, '00-%m-%d')) ) AS age FROM `users` WHERE ( (DATE_FORMAT(CURDATE(),'%Y') - DATE_FORMAT(`bdate`, '%Y') ) - ( DATE_FORMAT(CURDATE(), '00-%m-%d') < DATE_FORMAT( `bdate`, '00-%m-%d')) ) BETWEEN $age_from AND $age_to"; // if any of the options that are stored in the `users` table are selected, add AND to the query string, //and store each needed part in an array, $users_criteria if( $gender != "" || $first != "" || $last != "" ) { $query .= ' AND '; $users_criteria = array(); if( !empty($gender) ) { $users_criteria[] = "`gender` = '$gender'"; } if( !empty($first) ) { $users_criteria[] = "`first` LIKE '%$first%'"; } if( !empty($last) ) { $users_criteria[] = "`last` LIKE '%$last%'"; } $query .= implode( ' AND ', $users_criteria ); // implode the array, separating each part with AND, and append to query string } // Same process as above, but for results that come from `questions` table if( $smoke != '' || $drink != '' || $orientation != '' || $religious != '' || $ethnicity != '' || $bodytype != '' ) { $query .= ' AND id IN( SELECT `userid` FROM `questions` WHERE '; $questions_criteria = array(); if( !empty($smoke) ) { $questions_criteria[] = "`smoke` = '$smoke'"; } if( !empty($drink) ) { $questions_criteria[] = "`drink` = '$drink'"; } if( !empty($orientation) ) { $questions_criteria[] = "`orientation` = '$orientation'"; } if( !empty($religious) ) { $questions_criteria[] = "`religious` = '$religious'"; } if( !empty($ethnicity) ) { $questions_criteria[] = "`ethnicity` = '$ethnicity'"; } if( !empty($bodytype) ) { $questions_criteria[] = "`body_type` = '$bodytype'"; } if( !empty($children) ) { $questions_criteria[] = "`children` = '$children'"; } if( !empty($education) ) { $questions_criteria[] = "`education` = '$education'"; } $query .= implode( ' AND ', $questions_criteria ); $query .= ' LIMIT $skip, 2 )'; } echo "<table width='100%' align='center'>"; if( $result = mysql_query( $query ) ) { if( mysql_num_rows($result) > 0 ) { while( $rr3 = mysql_fetch_assoc($result) ) { $user=clean_up($rr3[id]); $first=clean_up($rr3[first]); $last=clean_up($rr3[last]); $avatar=clean_up($rr3['avatar']); $about=clean_up($rr3[about]); echo "<tr><td valign='top' width='140' class='content'><center><img src='avatars/thumb/$avatar' /><br><a href='index.php?action=profile&id=$user'> $first $last</a></center></td><td class='content' valign='top'>".limitdesc($about)."</td></tr>"; } } else { echo '<tr><td colspan="2">Sorry, your search returned no results.</td></tr>'; } } else { echo '<tr><td colspan="2">We\'re sorry, there has been an error processing your request. Please try later.</td></tr>'; } echo "</table>"; echo "<div class='content'><center>"; if($getpage == 0 || $getpage == 1){}else{ $plink = $getpage - 1; echo " <a href='index.php?action=search&page=$plink'>Previous</a> "; } echo "<select id='ddp' onchange='document.location=(ddp.value)'> <option value=''>Page #</option>"; for ($i = 1; $i <= $page_count; ++$i){ echo ' <option value="index.php?action=search&page=' . $i . '">' . $i . '</option>'; } echo "</select>"; if($getpage == $page_count){}else{ if($page_count>1){ if($getpage == 0){ echo " <a href='index.php?action=search&page=2'>Next</a> "; }else{ $nlink = $getpage + 1; echo " <a href='index.php?action=search&page=$nlink'>Next</a> "; } } } echo "</center></div>"; } include ('footer.php'); ?> I keep getting these errors: Code: [Select] Warning: Cannot modify header information - headers already sent by (output started at /home/gamersgo/public_html/datingsnap.com/header.php:4) in /home/gamersgo/public_html/datingsnap.com/pages/search.php on line 182 Warning: Cannot modify header information - headers already sent by (output started at /home/gamersgo/public_html/datingsnap.com/header.php:4) in /home/gamersgo/public_html/datingsnap.com/pages/search.php on line 183 the errors are coming from the setcookie lines. any idea why its spitting out that? and when I search, the results don't come out to two results per page. so the pagination isn't working right and i am getting those errors. any ideas? Hi guys, please go to this url , http://mcfly1111.blogspot.com/2011/01/pagination.html . i typed out everything there. ifyou can correct my codes, that will be great but any help will be appreciated, thanks! Hi gurus! Recently i am facing a tiny problem. I want to do is pagination like (<< PREVIOUS | INDEX | NEXT >>). My codes are below. Regards Code: [Select] <?php $SQL = mysql_query("SELECT id FROM blogmaster ORDER BY id DESC"); while($ROW = mysql_fetch_array($SQL)) { $MYARRAY[] = $ROW['id']; } $ARRAYCOUNT = count($MYARRAY); if($MYARRAY[0] != $_GET['id']) { $DESC = $MYARRAY[0] + 1; echo '<a href="/blog/detail.php?id=' .$MYARRAY[$DESC]. '" class="p-link"><< PREV</a> '; } echo '<a href="/blog/index.php" class="p-link">INDEX</a> '; if($MYARRAY[$ARRAYCOUNT] != $_GET['id']) { $ASC = $MYARRAY[$ARRAYCOUNT] - 1; echo '<a href="/blog/detail.php?id=' .$MYARRAY[$ASC]. '" class="p-link">NEXT >></a> '; } ?> Also how can i paginate something like <<PREV | 1 2 3 4 5 | NEXT>> when user reach page #5 and click NEXT link then page number should change <<PREV | 6 7 8 9 10 | NEXT>> |