Jump to content

Scroll to bottom or reverse order


SoireeExtreme

Recommended Posts

I was wondering if anyone could help me... I've been working on this for days and can't seem to figure it out. I've searched up and down everywhere. And I've come up with just about nothing.

 

Now I have two problems... I only need the answer to 1 of them. First would be forcing the scroll bar to the bottom of a chat box iframe where the messages are displayed. I've tried several different ways and the forcing doesn't work. The reason why I think it doesn't is because of the flush and sleep... But if take those out The page doesn't load correctly. Its like it freezes... So if anyone could help me get this to scroll to the bottom or load correctly that would be great....

 

 

Now if I can't get that to work above then my other solution would be to get the messages to appear in reverse order and have message new messages appear at the top of the chat box iframe instead of at the bottom. Hence taking care of the scrolling problem....

 

So if any of this can be done I would appreciate it greatly. And a GREAT BIG THANK YOU in advance....

 

 

<?php
include "lang.inc.php";
include '../connect.php';
?>
<html>
<head>

</head>

<Body onload="javascript:window.self.location.href='#bottom'">



<?php //iframe for chat module
set_time_limit(0);
include "../connect.php";
include "var.php";

$getrows="SELECT * from ch_messages";
$getrows2=mysql_query($getrows);
$getrows3=mysql_num_rows($getrows2);

$s=$getrows3-30;
if($s<0)
{
  $s=0;
}
$id=0;
while(!connection_aborted())
{
$id++;
print "<script type='text/javascript'>";
print "window.location.hash = 'm$id';";
print "</script>";

$getmessage="Select * from ch_messages  order  by time ASC limit $s,$getrows3";
$getmessage2=mysql_query($getmessage) or die("Could not get messages");
  while($getmessage3=mysql_fetch_array($getmessage2))
  {

$filter="$getmessage3[message]";

$smilies=array(
    ':^' => "<img src='images/icon_evil.gif'>",
    ':B' => "<img src='images/icon_idea.gif'>",
    'lol' => "<img src='images/icon_lol.gif'>",
    ':M' => "<img src='images/icon_mad.gif'>",
    ':r' => "<img src='images/icon_redface.gif'>",
    ':[' => "<img src='images/icon_sad.gif'>",
    ':S' => "<img src='images/icon_surprised.gif'>",
    ':w' => "<img src='images/icon_twisted.gif'>",
    '[]' => "<img src='images/icon_right.gif'>",

    '' => "<img src='images/icon_razz.gif'>",
    '' => "<img src='images/icon_biggrin.gif'>",
    '' => "<img src='images/icon_cool.gif'>",
    ':?' => "<img src='images/icon_confused.gif'>",
    ':c' => "<img src='images/icon_cry.gif'>",
    '' => "<img src='images/icon_eek.gif'>",
    '!' => "<img src='images/icon_exclaim.gif'>",
    ':}' => "<img src='images/icon_mrgreen.gif'>",
    ':l' => "<img src='images/icon_neutral.gif'>",
    '' => "<img src='images/icon_wink.gif'>",
    '' => "<img src='images/icon_smile.gif'>",
    ':~' => "<img src='images/icon_rolleyes.gif'>" );

$filter=str_replace(array_keys($smilies), array_values($smilies),
    $getmessage3[message]);

    if($getmessage3[registered]==1)
    {
      print "<font color='$registeredcolor'>$getmessage3[poster]</font>: $filter<br />";

      $s++;
       print "<A name='m$id'>";
    }
    else if($getmessage3[registered]==0)
    {
      print "<font color='$unregisteredcolor'>Unregistered</font>: $getmessage3[message]<br />";
      $s++;
       print "<A name='m$id'>";

    }

  }

if($s>=$getrows3)
{
   print "<a name='bottom'></a>";
  flush();
  sleep(1);
}
}

?>

</body></html>

Link to comment
Share on other sites

Thanks for the reply but that doesn't work. I've tried it already... It does change the order... But it doesn't enter a new message correctly when posted. And new messages still load at the bottom of the iframe instead of at the top of the iframe...

 

I need the new posted messages at the top of the iframe working its way down to the bottom showing the older messages that have been entered.

Link to comment
Share on other sites

Does this help?

 

 

--
-- Table structure for table `ch_messages`
--

CREATE TABLE IF NOT EXISTS `ch_messages` (
  `ID` bigint(21) NOT NULL auto_increment,
  `poster` varchar(255) collate latin1_general_ci NOT NULL default '',
  `message` mediumtext collate latin1_general_ci NOT NULL,
  `registered` int(11) NOT NULL default '0',
  `time` bigint(21) default NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=128 ;

-- --------------------------------------------------------

--
-- Table structure for table `ch_online`
--

CREATE TABLE IF NOT EXISTS `ch_online` (
  `ID` bigint(21) NOT NULL auto_increment,
  `sessionname` varchar(255) collate latin1_general_ci NOT NULL default '',
  `time` int(11) NOT NULL default '0',
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=43 ;

Link to comment
Share on other sites

bump again. Am I asking for help in the wrong place. Am I being misunderstood? Can't anyone help me out and point me in the right direction? Seems that the help around here is starting to go down hill...

 

Yeah, and comments like that will get you loads of help. Its not like where getting paid to be here, we volunteer our time. If you don't like it ask your questions somewhere else, but don't complain, sheesh.

Link to comment
Share on other sites

Can't give to much information and only done a quick read.

 

You want messages sent to appear at the top of a list of other messages, and go through in time/date posted order?

 

I would simply add a timestamp to the messages, and then ordering by the timestamp. That should order them by date or time posted.

 

Sorry I haven't got into to much info (about to go to get some sleep), but you should be able to find some stuff about ordering by timestamps etc.

Link to comment
Share on other sites

I know people volunteer their time here to help out. But aren't there suppose to be people actually working here to help a person out too? yeah I think so. Thats what happens when you offer such a service as this. People actually help you and dont' leave you sitting around...

 

I didn't come here to ask your opinion on such things anyways. I asked for help on something I was having a problem with but like I said the service and help here is doing downhill. I sat here waiting and waiting... But this isn't the first time this has happened that I sat here and had to repost my questions.

 

But if this is the kind of help and comments I'm going to get from people like you around here then I surely don't need to be here. Not in a place amoung losers who think the are on top of the world when they aren't Mr. Super Mod... Like I said I didn't ask for you opinion. I asked for help. So be helpful or shut your trap!

 

But doesn't matter I'm not coming around here again. And its people like you why this world is and turning more and more into a crap hole of a place...

 

I was making a simple statement that the help is going downhill. So there was no need for you lame remarks as you so stated! But this is my last post here! Hope you have a horrible life and wish you all the bad luck in the world.....................................

;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D:D :D :D :D :D :D :D :D

 

 

.

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.