runnerjp Posted May 28, 2008 Share Posted May 28, 2008 hey guys just a quick one... my forum below... how can i display the messages by newest 1st? <?php include "connect.php"; //mysql db connection here $id=$_GET['id']; print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<A href='index.php?page=index'>Back to main forum</a>-<A href='index.php?page=post'>New Topic</a>-<A href='index.php?page=reply&id=$id'>Reply<br>"; print "<table class='maintable'>"; print "<tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr>"; $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); print "<tr class='mainrow'><td valign='top'>$gettopic3[author]</td><td vakign='top'>Last replied to at $gettopic3[showtime]<br><hr>"; $message=strip_tags($gettopic3['post']); $message=nl2br($message); print "$message<hr><br>"; print "</td></tr>"; $getreplies="Select * from forumtutorial_posts where parentid='$id' order by postid DESC LIMIT 0, 1"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { print "<tr class='mainrow'><td valign='top'>$getreplies3[author]</td><td vakign='top'>Last replied to at $getreplies3[showtime]<br><hr>"; $message=strip_tags($getreplies3['post']); $message=nl2br($message); print "$message<hr><br>"; print "</td></tr>"; } print "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/ Share on other sites More sharing options...
Daniel0 Posted May 28, 2008 Share Posted May 28, 2008 Add ORDER BY field DESC to your query. Replace field with the field you want it ordered by. Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551562 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 ok thats working well but i have a new problem <table class='maintable'> <tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr> <?php $getreplies="Select * from forumtutorial_posts where parentid='$id' ORDER BY showtime DESC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?> <tr class='mainrow'><td valign='top'><?php echo $getreplies3[author]?> </td><td vakign='top'>Last replied to at <?php echo $getreplies3[showtime]?> <br><hr><?php $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <?php echo $message?> <hr><br> </td></tr><?php $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); ?><tr class='mainrow'><td valign='top'><?php echo $gettopic3[author] ?> </td><td vakign='top'>Last replied to at <?php echo $gettopic3[showtime]?><br><hr><? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <?php echo $message ?> <hr><br> as you can see i have it so my replies are above my 1st message in topic ( the message that started the topic) the problem is it does this starting message a reply starting message anoouther reply starting message where i just want it to be a reply anoouther reply starting message Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551643 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 ok been thinkin and its a silly idea as people will want to know what the message is lol... but i have a new question... from <?php include "connect.php"; //mysql db connection here $id=$_GET['id']; ?> <link rel='stylesheet' href='style.css' type='text/css'> <A href='index.php?page=index'>Back to main forum</a>-<A href='index.php?page=post'>New Topic</a>-<A href='index.php?page=reply&id=<? echo $id; ?>'>Reply<br> <table class='maintable'> <tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr> <? $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); ?> <tr class='mainrow'><td valign='top'><? echo $gettopic3[author] ?> </td><td vakign='top'>Last replied to at <? echo $gettopic3[showtime]?><br><hr><? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?> <hr><br> </td></tr><? $getreplies="Select * from forumtutorial_posts where parentid='$id' ORDER BY showtime DESC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?><tr class='mainrow'><td valign='top'><? echo $getreplies3[author]?> </td><td vakign='top'>Last replied to at <? echo $getreplies3[showtime]?> <br><hr><? $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <? echo $message?> <hr><br> </td></tr> } ?> how cna i make it so that it only diplays 10 posts on one page then it has page 1234 ect like on here? Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551655 Share on other sites More sharing options...
revraz Posted May 28, 2008 Share Posted May 28, 2008 That's called Pagination. There is a tutorial for it somewhere around here. Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551660 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 thanks lol been looking for google at what you call it lol... Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551663 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 iv looked at a few tutorials but im abiot stumped how im supposed to add it to my existing code :S Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551669 Share on other sites More sharing options...
soycharliente Posted May 28, 2008 Share Posted May 28, 2008 Try taking an existing page with pagination in it already and adding your code. Make it display your data instead of adding in the pagination around your code. Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551687 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 ok been going through it and im still alittle puzzed how i cna add this if <?php (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if$query = "SELECT count(*) FROM table WHERE ..."; $result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 15; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $query = "SELECT * FROM table $limit"; $result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR); ... process contents of $result ... if ($pageno == 1) { echo " FIRST PREV "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> "; } // if echo " ( Page $pageno of $lastpage ) "; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> "; } // if ?> [code] to this PHP Code:[code] <?php include "connect.php"; //mysql db connection here $id=$_GET['id']; ?> <link rel='stylesheet' href='style.css' type='text/css'> <A href='index.php?page=index'>Back to main forum</a>-<A href='index.php?page=post'>New Topic</a>-<A href='index.php?page=reply&id=<?php echo $id; ?>'>Reply<br> <table class='maintable'> <tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr> <?php $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); ?> <tr class='mainrow'><td valign='top'><?php echo $gettopic3[author] ?> </td> <td vakign='top'>created on <?php echo $gettopic3[showtime]?><br> <hr> <p> <?php $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?></p> <p><br> </p></td></tr><?php $getreplies="Select * from forumtutorial_posts where parentid='$id' ORDER BY showtime DESC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?><tr class='mainrow'><td valign='top'><?php echo $getreplies3[author]?> </td><td vakign='top'>replied at <?php echo $getreplies3[showtime]?> <br> <hr> <p> <?php $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <?php echo $message?></p> <p><br> </p></td></tr> <? } ?> </table> runnerjp is online now Add to runnerjp's Reputation Report Post Thanks Edit/Delete Message[/code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551699 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 sorry should have been this <?php (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if$query = "SELECT count(*) FROM table WHERE ..."; $result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 15; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $query = "SELECT * FROM table $limit"; $result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR); ... process contents of $result ... if ($pageno == 1) { echo " FIRST PREV "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> "; } // if echo " ( Page $pageno of $lastpage ) "; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> "; } // if ?> with this <?php include "connect.php"; //mysql db connection here $id=$_GET['id']; ?> <link rel='stylesheet' href='style.css' type='text/css'> <A href='index.php?page=index'>Back to main forum</a>-<A href='index.php?page=post'>New Topic</a>-<A href='index.php?page=reply&id=<? echo $id; ?>'>Reply<br> <table class='maintable'> <tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr> <? $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); ?> <tr class='mainrow'><td valign='top'><? echo $gettopic3[author] ?> </td> <td vakign='top'>created on <? echo $gettopic3[showtime]?><br> <hr> <p> <? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?></p> <p><br> </p></td></tr><? $getreplies="Select * from forumtutorial_posts where parentid='$id' ORDER BY showtime DESC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?><tr class='mainrow'><td valign='top'><? echo $getreplies3[author]?> </td><td vakign='top'>replied at <? echo $getreplies3[showtime]?> <br> <hr> <p> <? $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <? echo $message?></p> <p><br> </p></td></tr> <? } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551867 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 ok i have put it together but its not doint what it should do... it displays page 1 of 1 no matter how many results it has :S the highlighted is the pagination and the dark iv left unedited wih php so you can see the information thats show <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"> <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css"> <?php include "connect.php"; //mysql db connection here $id=$_GET['id']; //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * from forumtutorial_posts where postid='$id'") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * from forumtutorial_posts where postid='$id' $max") or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array( $data_p )) { Print $info['Name']; echo "<br>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> <A href='index.php?page=index'>Back to main forum</a>-<A href='index.php?page=post'>New Topic</a>-<A href='index.php?page=reply&id=<? echo $id; ?>'>Reply<br> <table class='maintable'> <tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr> <? $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); ?> <tr class='mainrow'><td valign='top'><? echo $gettopic3[author] ?> </td> <td vakign='top'>created on <? echo $gettopic3[showtime]?><br> <hr> <p> <? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?></p> <p><br> </p></td></tr><? $getreplies="Select * from forumtutorial_posts where parentid='$id' ORDER BY showtime DESC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?><tr class='mainrow'><td valign='top'><? echo $getreplies3[author]?> </td><td vakign='top'>replied at <? echo $getreplies3[showtime]?> <br> <hr> <p> <? $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <? echo $message?></p> <p><br> </p></td></tr> <? } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551928 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 ok a little bit more messing around and i now have <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"> <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/members/include/style.css"> <?php include "connect.php"; //mysql db connection here $id=$_GET['id']; //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * from forumtutorial_posts where parentid='$id'") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * from forumtutorial_posts where parentid='$id' $max") or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array( $data_p )) { ?><A href='index.php?page=index'>Back to main forum</a>-<A href='index.php?page=post'>New Topic</a>-<A href='index.php?page=reply&id=<? echo $id; ?>'>Reply<br> </A> <table class='maintable'> <tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr> <? $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2); ?> <tr class='mainrow'><td valign='top'><? echo $gettopic3[author] ?> </td> <td vakign='top'>created on <? echo $gettopic3[showtime]?><br> <hr> <p> <? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?></p> <p><br> </p></td></tr><? $getreplies="Select * from forumtutorial_posts where parentid='$id'"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?><tr class='mainrow'><td valign='top'><? echo $getreplies3[author]?> </td><td vakign='top'>replied at <? echo $getreplies3[showtime]?> <br> <hr> <p> <? $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <? echo $message?></p> <p><br> </p></td></tr> <? } ?> </table><? echo "<br>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> but its repeats the WHOLE forum 4 times an not the "Select * from forumtutorial_posts where parentid='$id'"; which gets the number of replys :S Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-551953 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 does any of this make sence or do i need to add more information?? Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552001 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 i could really do with some help is it because im gathering 2 bits of data? Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552089 Share on other sites More sharing options...
runnerjp Posted May 28, 2008 Author Share Posted May 28, 2008 ok i have got it working BUT is there away i can show this <?php $gettopic="SELECT * from forumtutorial_posts where postid='$id'"; $gettopic2=mysql_query($gettopic) or die("Could not get topic"); $gettopic3=mysql_fetch_array($gettopic2);?> only 1ns as it appears ontop of all the pages Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552110 Share on other sites More sharing options...
runnerjp Posted May 29, 2008 Author Share Posted May 29, 2008 so it just appears on page 1 Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552349 Share on other sites More sharing options...
runnerjp Posted May 29, 2008 Author Share Posted May 29, 2008 ok i tired $gettopic="SELECT * from forumtutorial_posts where postid='$id'LIMIT [1,]1"; but didnt work Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552547 Share on other sites More sharing options...
soycharliente Posted May 29, 2008 Share Posted May 29, 2008 ok a little bit more messing around and i now have... but its repeats the WHOLE forum 4 times an not the "Select * from forumtutorial_posts where parentid='$id'"; which gets the number of replys :S because I don't see where you were actually running that query. You saved it to $data_p (I think), but never ran mysql_query on it. I hope this helps. I haven't tested this because I don't have your db. It was sort of hard to pick through all the code that you've been posting and understand your incomplete sentences. <?php require("connect.php"); //mysql db connection here // use require so that if it doesn't connect to the db, // then it won't try to process the page. function myEscape($string) { $new = get_magic_quotes_gpc() ? stripslashes($string) : $string; $safe = mysql_real_escape_string($new); return $safe; } $id = $_GET['id']; foreach ($_GET as $key => $val) { $_GET[$key] = myEscape($val); } if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if $query = "SELECT COUNT(*) FROM `table` WHERE `postid`='$id'"; $result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 15; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $query = "SELECT * FROM table WHERE `postid`='$id' ORDER BY `showtime` DESC $limit"; $result = mysql_query($query, $db) or die("Could not get topic."); if (mysql_num_rows($result) > 0) { echo "<table class=\"maintable\">"; echo "<tr class=\"headline\"><td width=\"20%\">Author</td><td width=\"80%\">Post</td></tr>"; while ($row = mysql_fetch_array($result)) { $author = $row['author']; $showtime = $row['showtime']; $message = nl2br(strip_tags($row['post'])); echo "<tr class=\"mainrow\">"; echo "<td valign=\"top\">{$author}</td>"; echo "<td vakign=\"top\">replied at {$showtime} <br /><hr><p>{$message}</p></td>"; echo "</tr>"; } echo "</table>"; } else { // show an error message? } // if if ($pageno == 1) { echo " FIRST PREV "; } else { echo " <a href=\"{$_SERVER['PHP_SELF']}?pageno=1\">FIRST</a> "; $prevpage = $pageno-1; echo " <a href=\"{$_SERVER['PHP_SELF']}?pageno={$prevpage}\">PREV</a> "; } // if echo " ( Page $pageno of $lastpage ) "; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno + 1; echo " <a href=\"{$_SERVER['PHP_SELF']}?pageno={$nextpage}\">NEXT</a> "; echo " <a href=\"{$_SERVER['PHP_SELF']}?pageno={$lastpage}\">LAST</a> "; } // if ?> Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552566 Share on other sites More sharing options...
runnerjp Posted May 29, 2008 Author Share Posted May 29, 2008 ok changed it a little but gave me gr8 pointer thanks for spendin time doing that cheers..... SOLVED! Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552595 Share on other sites More sharing options...
soycharliente Posted May 29, 2008 Share Posted May 29, 2008 Posting the final solution that worked is always a good idea. Share the knowledge. Plenty of people have trouble with pagination. Maybe your working code could help someone else. Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552616 Share on other sites More sharing options...
runnerjp Posted May 29, 2008 Author Share Posted May 29, 2008 ok i have a new problem... messign around with the reply area and i have done this <? $getreplies="Select * from forumtutorial_posts where parentid='$id'ORDER BY showtime DESC"; //getting replies $getreplies2=mysql_query($getreplies) or die("Could not get replies"); while($getreplies3=mysql_fetch_array($getreplies2)) { ?><tr class='mainrow'><td valign='top'><? echo $getreplies3[author]?> </td><td vakign='top'>replied at <? echo $getreplies3[showtime]?> <br> <hr> <p> <? $message=strip_tags($getreplies3['post']); $message=nl2br($message); ?> <? echo $message?></p> <p><br> </p></td></tr> <tr class='mainrow'> <td valign='top'><? echo $gettopic3[author] ?></td> <td vakign='top'>created on <? echo $gettopic3[showtime]?><br /> <hr /> <p> <? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?></p></td> </tr> <? } ?> </table> but the trouble is starting message a reply starting message anoouther reply starting message where i just want it to be a reply anoouther reply starting message can i limit <tr class='mainrow'> <td valign='top'><? echo $gettopic3[author] ?></td> <td vakign='top'>created on <? echo $gettopic3[showtime]?><br /> <hr /> <p> <? $message=strip_tags($gettopic3['post']); $message=nl2br($message); ?> <? echo $message ?></p></td> </tr> to only be shown 1ns?? Quote Link to comment https://forums.phpfreaks.com/topic/107612-forum/#findComment-552820 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.