PHP mysql - Creating next and previous link (error with my solution) -
This is the sequel to another question I asked:
Let me address this solution next and previous. Now I need to transform it into some useful PHP code.
Then there is a Heres solution:
Select the CD from the database WHERE (id = (SELECT MAX (id) database from WHERE id & lt; c.id and language = ' N ') or id = (select WHERE id from the MIN (id) database> c.id and language =' n ')) I will put a next and previous link from this How to make
What I tried:
$ result = mysql_query ("Select ID from database id ASER WHERE (ID = (Select MAX ID) from the database WHERE ID & Lt; c.id and language = 'n') or id = (select WHERE id from the MIN (id) database> c.id and language = 'n')) "); While ($ line = mysql_fetch_array ($ result)) {$ nextlink = "& lt; a href = 'http: //www.domain.com/". $ Line ['c.id']. ".html '& gt; Next & lt; / a & gt;"; Echo $ nextlink; } It does not show anything. Another problem is that I need to remove another column_name named Permenink, so the next link can be completed.
Please consider me as a PHP novice, so you have to make it clear Thanks
EDIT: I realized that the ID in the solution is not included anywhere?
I believe that you want to see something more like this: < Pre> SELECT c.id, (select MAX (p.id) database p from WHERE p.id & lt; c .id and p.language = 'en') prev_id (from database where number n.id) N.id & gt; C.id and n.language = 'en') from the next_id database AS c WHERE c.id = [current state] Then, your SQL will address only one line: / P>
while ($ row = mysql_fetch_array ($ result)) {$ Prevlink = "& lt; a href = 'http: //www.domain.com/") Line ['c.prev_id'] ... Html '& gt; Previous & lt; / A & gt; "; $ Nextlink =" & lt; A href = 'http: //www.domain.com/' $ Line ['c.nexT_id']. ".html '& gt; Next & lt; / a & gt;"; Echo $ nextlink; }
Comments
Post a Comment