I have contents in db and all have id's title's and links. blah1.php blah2.php blah3.php .......... When viewing blah1.php i want to display a link for blah2.php and goes as in blah2.php a link for blah1.php and blah3.php as [next link- prev link]. Can you help please?
If you are generating the pages from a database you should be able to echo the id number of 2 if you are on blah2.php or 3 if you are on blah3.php to the screen. Then you simply do $nextpage=$currentpage+1; echo"<a href=\"blah$nextpage.php\">Next Page</a>"; PHP:
With that code which ever page i view it echos 1.php as "next page" link. Maybe it ll be better to give more details. I added id numbers, titles and page links to the db. So the row is like id title link 1 atitle atitle-is-atitle 2 btitle btitle-is-btitle 3 ctitle ctitle-is-ctitle 4 dtitle dtitle-is-dtitle .......... Code (markup): I $_GET the id numbers of links from left menu and display on index page as <? echo '' .$result[title];?>. I want to print the next link on db there too.
hi kirpy, i'm not sure if thats what u need, but... : if ($currentpageID >1) { $prevpageID = $currentpageID - 1; echo"<a href=\"$prevpageID.php\">Prev Page</a>"; } if ($currentpageID < count($pagecount)) { $nextpageID = $currentpageID + 1; echo"<a href=\"$nextpageID.php\">Next Page</a>"; } PHP: hope it helps...
kirpy, i only gave u concept to make it work u need to define in every blahX.php the $currentpageID, for example: in blah1.php add line $currentpageID = 1; PHP: in blah2.php $currentpageID = 2; PHP: and so on... moreover in every blahX.php $pagecount must be defined, so u need to get this variable from your db... with MySQL it would be something like: $link = mysql_connect ('server','user','pass'); mysql_select_db('database', $link); $result = mysql_query('SELECT * FROM name_of_the_table_with_your_data', $link); $pagecount = mysql_num_rows($result); PHP: and the rest of the code would stay as it was (except the count($pagecount) function, which in this case is unnesesary) : if ($currentpageID >1) { $prevpageID = $currentpageID - 1; echo"<a href=\"$prevpageID.php\">Prev Page</a>"; } if ($currentpageID < $pagecount) { $nextpageID = $currentpageID + 1; echo"<a href=\"$nextpageID.php\">Next Page</a>"; } PHP: heh its getting complicated, hope it helps ...or maybe i'm missing ur point?