Jump to content

Show all/Show 10 records in a shoutbox


jakeoh

Recommended Posts

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++;

}

 

?>

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.