Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:46:06+00:00 2026-06-02T19:46:06+00:00

I am implementing chat using PHP, SQL, JavaScript. I am checking for new messages

  • 0

I am implementing chat using PHP, SQL, JavaScript. I am checking for new messages by reloading the same file using window.location.replace(‘chatlog.php’)
So the page is redirected to itself after every interval. When there are more number of messages, I am getting a scroll bar at the side, and as the page is reloading I had to scroll it to see the last posted message every time is refreshes which is hard to do.
How do I write the code so that the last posted message is displayed even the page reloads?

Some part of the chat.php file is as below

while($record=$mysql_fetch_array($sql))
{
print "<font color="brown">$record[firstname]:</font><font color="black">$record[message]</font>";
}
<script>
setTimeout("window.location.replace('chatlog.php')",2000);
</script>

Can AJAX be used to solve this? If so, how do we do that ?

I have another question. I am storing timestamp in sql table as year-month(in numbers)-date hours:min:sec
I want to display it in month date at time am/pm for example (April 23rd 2012 at 5pm)
How do I convert to this? Are there any php functions to convert?
Please help !!!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:46:07+00:00Added an answer on June 2, 2026 at 7:46 pm

    The simplest solution is to just put an <a name="msgID_$id">...</a> name anchor on each message, eg:

    <a name="msgID_1">msg 1</a> ...
    <a name="msgID_2">msg 2</a> ...
    etc...
    <a name="msgID_20">msg 20</a> ...
    

    then embed a refresh that has an anchor corresponding to the LAST msg ID you listed on the page:

    example.com/msgs.php#msgID_20
    

    when the page refreshes, the browser will auto-scroll to that message, and the new refresh’s anchor will have the ID of the newest message instead (e.g. #msgID_25).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was thinking of implementing real time chat using a PHP backend, but I
I'm implementing a little chat application where I receive messages from a server, which
implementing publishActivity in PHP using the REST API using this code: $activity = array(
I am implementing chat in my application, very similar to the iPhone's built-in Messages
I'm creating an online chat. Context (if needed): So far I was using PHP/MySQL
Implementing the SQL Server Session Provider by using aspnet_regsql. In Web Config <sessionState mode
which one is better for implementing chat for the iPhone with users in the
Possible Duplicate: Facebook's horizontal scrollbar in ticker & chat sidebar I am implementing a
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I've implemented a web based instant messaging / chat feature using http binding and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.