Search the Community
Showing results for tags 'php mysql blog noob id links'.
-
my problems is propably very simple.. :/ Some of my code.. if(isset($_GET['next'])){ $ID = $_GET['ID']; $ID=$ID+1; } elseif(isset($_GET['prev'])){ $ID = $_GET['ID']; $ID=$ID-1; }else{ $ID = 1; } mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name WHERE ID = $ID"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> problem 1 Red = shows the first post i wrote.. i need it to show the most resent? Http://adress.com/?page=Blog2&ID=1&next=1 Problem 2 Green = the adress' for the diffent post shows like this.. how do i link to a specific post? ex. Http://adress.com/?page=Blog2&ID=2 does not work? the &ID=1&next=1 works fine for me but then again am i on post 1 there is still a link for the post before :/ that does not exsist and the latest post still have a next post link please help many thanks the self learned php dummy Tobias Nielsen the whole page looks like this if i didnt get all you needed in top part.... SORRY Iam from denmark so my english sucks and my blog is in danish >_< <BODY> <?php $host="HOST"; $username="username"; $password="password"; $db_name="dbname"; $tbl_name="blog"; if(isset($_GET['next'])){ $ID = $_GET['ID']; $ID=$ID+1; } elseif(isset($_GET['prev'])){ $ID = $_GET['ID']; $ID=$ID-1; }else{ $ID = 1; } mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name WHERE ID = $ID"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <br><center> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <th scope="col"><table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <th width="100" height="99" rowspan="2" background="Resources/Img/Layout/Kalender/2012.png" scope="col"><table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> <th height="46" valign="bottom" scope="col" id="db-dato-text"><? echo $rows['dato']; ?></th> </tr> <tr> <th class="style3" scope="row"> </th> </tr> </table></th> <th height="41" align="left" valign="bottom" scope="col" id="db-title-text"> <p><? echo $rows['title']; ?><br /> </p></th> </tr> <tr> <th align="left" valign="top" scope="col" id="db-info-text"><p> Indlæg nr : <? echo $rows['id']; ?><br> Sted : <? echo $rows['sted']; ?><br> Klokken : <? echo $rows['klokken']; ?><br /> </p></th> </tr> </table> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <th width="153" scope="col" id="blog-indlæg-text"><div align="left"><br><? echo $rows['indlæg']; ?><br /><br><br> <br /> </div></th> </tr> </table></th> </tr> </table><br><br> <table width="500"> <tr> <td width="100" id="tidligere-post"><? echo '<a href="?page=Blog2&ID='.$ID.'&prev=1"><b>Forrige indlæg</b></a>'; ?></td> <td width="300" > </td> <td width="100" id="nyere-post"><? echo '<a href="?page=Blog2&ID='.$ID.'&next=1"><b>Nyere indlæg</b></a>'; ?></td> </tr> </table> <br></center> <?php } mysql_close(); ?></BODY>