Jump to content

Recommended Posts

the prob was

i didn't know how to make it work

like who is online

and click

show

and everything. Can some 1 pls help me

 

 

 

<?php session_start();

mysql_connect("localhost","root","") or die(mysql_error());

mysql_select_db("chat");

$mandeep = '<img src="img/mandeep.png" height="32" width="32" style="margin-right:10px;" />';

$adhar = '<img src="../design/images/no-image/search.png" height="32" width="32" style="margin-right:10px;" />';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>demo chat</title>

<link href="css/chat_css.css" rel="stylesheet" type="text/css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="js/jquery-1.6.2.js"></script>

</head>

 

<body>

<script type="text/javascript" >

 

$(function() {

$("#name-form-1").submit(function() {

var check_chat = $('adhar_message').val();

if(check_chat==""&&check_chat==null){

 

}else {

$.ajax({

type: "POST",

url: "submit.php",

data: $('#name-form-1').serialize(),

dataType: "json",

complete: function(){

$("#check_chat").load('submit.php?chat_update=chat_update');

$("#mandeep_message").val('');

}

})

$('.check_area').animate({scrollTop: $('.check_area')[0].scrollHeight});

return false;

}

});

 

});

</script>

<script type="text/javascript" >

 

$(function() {

$("#name-form").submit(function() {

var check_chat = $('adhar_message').val();

if(check_chat==""&&check_chat==null){

return false;

}else {

$.ajax({

type: "POST",

url: "submit.php",

data: $('#name-form').serialize(),

dataType: "json",

complete: function(){

$("#check_chat").load('submit.php?chat_update=chat_update');

$("#adhar_message").val('');

}

})

 

$('.check_area').animate({scrollTop: $('.check_area')[0].scrollHeight});

return false;

}

});

});

</script>

<div class="chat_box" id="adhar">

    <div style="width:320px; float:left ; text-align:left">Adhar</div>

    <div class="check_area"src="submit.php?chat_update=chat_update" scrolling="auto"  >

    <div id="check_chat"  style="width:200px; height:auto; min-height:20px; float:left; max-width:200px">

        </div>

        <?php

$mycheck = mysql_query("select MAX(id) from chat");

$row_last = mysql_fetch_array($mycheck);

$max = $row_last['MAX(id)'];

$i=1;

while($i<=$max){

if(isset($oi)){$myo =mysql_query("select * from chat where ID='".$oi."'");

$rowo = mysql_fetch_array($myo);

}

$my =mysql_query("select * from chat where ID='".$i."'");

$row = mysql_fetch_array($my);

if($row['ADHAR_MESSAGE']==""&&$row['MANDEEP_MSG']!=""){

if(isset($rowo['MANDEEP_MSG'])&&$rowo['MANDEEP_MSG']==""){

echo '<div class="top_border"></div><div class="p_m"></div><div class="chat_text">'.$row['MANDEEP_MSG'].'</div>';

}else{

echo '<div class="chat_text">'.$row['MANDEEP_MSG'].'</div>';

}

}

else if($row['MANDEEP_MSG']==""&&$row['ADHAR_MESSAGE']!=""){

if(isset($rowo['ADHAR_MESSAGE'])&&$rowo['ADHAR_MESSAGE']==""){

echo '<div class="top_border"></div><div class="p_a"></div><div class="chat_text">'.$row['ADHAR_MESSAGE'].'</div>';

}else{

echo '<div class="chat_text">'.$row['ADHAR_MESSAGE'].'</div>';

}

}

$oi=$i;

$i++;

}

?>

    </div>

   

    <form action="submit.php" method="post" id="name-form">

    <input type="text" autocomplete="off" value="" id="adhar_message" name="adhar_message" />

    </form>

</div>

<div class="chat_box" id="mandeep">

Mandeep

<div class="check_area"src="submit.php?chat_update=chat_update" scrolling="auto"  >

    <div id="check_chat"  style="width:200px; height:auto; min-height:20px; float:left; max-width:200px">

        </div>

        <?php

$mycheck = mysql_query("select MAX(id) from chat");

$row_last = mysql_fetch_array($mycheck);

$max = $row_last['MAX(id)'];

$i=1;

while($i<=$max){

if(isset($oi)){$myo =mysql_query("select * from chat where ID='".$oi."'");

$rowo = mysql_fetch_array($myo);

}

$my =mysql_query("select * from chat where ID='".$i."'");

$row = mysql_fetch_array($my);

if($row['ADHAR_MESSAGE']==""&&$row['MANDEEP_MSG']!=""){

if(isset($rowo['MANDEEP_MSG'])&&$rowo['MANDEEP_MSG']==""){

echo '<div class="top_border"></div><div class="p_m"></div><div class="chat_text">'.$row['MANDEEP_MSG'].'</div>';

}else{

echo '<div class="chat_text">'.$row['MANDEEP_MSG'].'</div>';

}

}

else if($row['MANDEEP_MSG']==""&&$row['ADHAR_MESSAGE']!=""){

if(isset($rowo['ADHAR_MESSAGE'])&&$rowo['ADHAR_MESSAGE']==""){

echo '<div class="top_border"></div><div class="p_a"></div><div class="chat_text">'.$row['ADHAR_MESSAGE'].'</div>';

}else{

echo '<div class="chat_text">'.$row['ADHAR_MESSAGE'].'</div>';

}

}

$oi=$i;

$i++;

}

?>

    </div>

 

<div class="input_cheat_chat">

<form action="submit.php" method="post" id="name-form-1">

<input type="text" autocomplete="off" value=""id='mandeep_message' name="mandeep_message" />

   

</form>

</div>

</div>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/253580-ajax-help/
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.