redarrow Posted June 11, 2006 Share Posted June 11, 2006 Can some one help me i need to add a prev and next with numbers but i tried but failed cheers.If the user has more then 1 message the user can press prev next and number.[code]$query="select * from member_messages where id='$id'";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><table>";echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message: <font color='red'>Read</b></font></td></table><br><br>";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/ Share on other sites More sharing options...
redarrow Posted June 11, 2006 Author Share Posted June 11, 2006 [code]<?if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 10; $from = (($page * $max_results) - $max_results); $query="select * from member_messages where id='$id' LIMIT $from, $max_results";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><table>";echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message: <font color='red'>Read</b></font></td></table><br><br>";}$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM member_messages"),0);echo "<center>Select a Page<br />"; if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/#findComment-44266 Share on other sites More sharing options...
joquius Posted June 11, 2006 Share Posted June 11, 2006 Well what exactley isn't working with it at the moment?"If the user has more then 1 message the user can press prev next and number."In this one it's over 10 though Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/#findComment-44271 Share on other sites More sharing options...
redarrow Posted June 11, 2006 Author Share Posted June 11, 2006 This is the code so far as the above was wrong know the message is showwing the two messages when the second should be on the page number 2 but issint lol cheers[code]if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 10; $from = (($page * $max_results) - $max_results); $query="select * from member_messages where id='$id' LIMIT $from, $max_results";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><table>";echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message: <font color='red'>Read</b></font></td></table><br><br>";}$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM member_messages"),0); $total_pages = ceil($total_results / $max_results); echo "<center>Select a Page<br />"; if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/#findComment-44272 Share on other sites More sharing options...
joquius Posted June 11, 2006 Share Posted June 11, 2006 $max_results = 10;change it to 1 Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/#findComment-44274 Share on other sites More sharing options...
redarrow Posted June 11, 2006 Author Share Posted June 11, 2006 [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--][code]if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 1; $from = (($page * $max_results) - $max_results); $query="select * from member_messages where id='$id' LIMIT $from, $max_results";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<table width='200'border='4' bordercolor='black'><td align='center'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><table>";echo "<table width='200'border='4' bordercolor='black'><td align='center'><b>Read Message: <font color='red'>Read</b></font></td></table><br>";}$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM member_messages where id='$id'"),0); $total_pages = ceil($total_results / $max_results); echo "<center><b>Select A Message!</b><br>"; if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\">Previous>></a>"; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/#findComment-44277 Share on other sites More sharing options...
redarrow Posted June 11, 2006 Author Share Posted June 11, 2006 i got a slight problamas you can see from the above code i am using it for users to look at who sent a message. but when i want to go to to a read page to read that message i get all the messages in the databasewith a while loop.example if i press 1 i get the two messages in the database i did try limit 1 but if you then goto page 2 you only get message 1 on the read page.From the code above how do you get a link to corerspond to the data in the database so if link 2 had message from god then you see message from god on the read page.i tried page=$page&id='$id' // dont workalso the otherway around.so the quiestion is how do you get the data in a database to be seen from a pagatinton to another page.or otherwise i have to show all messages and theat defeats the code get meheres the read.php page example[code]$db=mysql_connect("localhost","root","admin");mysql_select_db("promotor",$db);$query="select * from member_messages where id='$id'";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<table align='center' width='300'border='4' bordercolor='black'><td align='left'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><td align='center' valign='top'><b>Members Message<b><br><br><b><div align='left'><textarea col='7' rows='7'style='color: white; background-color: #A0C0F0'>".$record["message"]."</textarea></td></b></div><table>";echo "<table align='center' width='300'border='4' bordercolor='black'><td align='center'><b>Send A Reply <font color='red'><a href='send_message.php?&id=$id'>reply</a></b></font></td></table><br>";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11707-prev-next-123-help-cheers/#findComment-44297 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.