jakeoh Posted October 9, 2007 Share Posted October 9, 2007 Hi, I added a shout box to my website after following a tutorial I found on the net. However there is a problem; the shoutbox displays all messages, so in the end it will end up being way too big. I would like to display 10 records (messages), for example, and then add a "View all" link at the bottom of the 10 messages; when a user would click on this link, the rest of the messages would be displayed, but in a given area and scroll bars would be used in order to see all messages. Do you have any idea how this could be done? I am quite new at PHP and MySQL. Here's the code for the page that displays the messages: <? include("Include/shoutbox_connect.php"); open_connection(); $shout_query = "SELECT * FROM shoutbox ORDER BY `date` DESC"; $shout_result = mysql_query($shout_query); $count = 0; while($shout_row = mysql_fetch_array($shout_result)) { $shouter_name = $shout_row['username']; $shout_content = $shout_row['content']; $shout_content = stripslashes($shout_content); $shout_date = $shout_row['date']; $dday = substr($shout_date, 8, 2); $dmonth = substr($shout_date, 5, 2); $dyear = substr($shout_date, 0, 4); if(($count % 2) != 0) { echo "<p class='odd'>$shouter_name - $shout_content - $dday-$dmonth-$dyear</p>"; } else { echo "<p class='even'>$shouter_name - $shout_content - $dday-$dmonth-$dyear</p>"; } $count++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72544-show-allshow-10-records-in-a-shoutbox/ Share on other sites More sharing options...
MasterACE14 Posted October 10, 2007 Share Posted October 10, 2007 try changing this line: <?php $shout_query = "SELECT * FROM shoutbox ORDER BY `date` DESC"; to this: <?php $shout_query = "SELECT * FROM shoutbox ORDER BY `date` DESC LIMIT 10"; Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/72544-show-allshow-10-records-in-a-shoutbox/#findComment-365802 Share on other sites More sharing options...
jakeoh Posted October 10, 2007 Author Share Posted October 10, 2007 Thanks! So I'm halfway there. How can I get the user to click on a link so that he can see all comments that have been posted so far? I guess I would use the same query as before, but I can make it so that all these comments are contained within a certain height, with scroll bars if necessary? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/72544-show-allshow-10-records-in-a-shoutbox/#findComment-365811 Share on other sites More sharing options...
jakeoh Posted October 10, 2007 Author Share Posted October 10, 2007 Anyone? I messed up the question in the previous post, what I wanted to ask is: How can I make it so that all these comments are contained within a certain height, with scroll bars if necessary? Quote Link to comment https://forums.phpfreaks.com/topic/72544-show-allshow-10-records-in-a-shoutbox/#findComment-366131 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.