Jump to content

Reload a page


shamsuljewel

Recommended Posts

I have a friends list getting from database.

When I click a link delete

that call a ajax function name request3 which delete the specific data from the database...and show the information in top div.

but in the below div the deleted data still remains unchanged cos the page didn't refreshed.

so how do i do that the below div will also refreshed so that it shows the current data?

any help please..??

Link to comment
Share on other sites

ok here is the code this is frnd_req.php file

<DIV id="running"></DIV>
	<div id="req">
		<table width="100%">
		<?php
		$ro=0;
		if($total_pending > 0){	
			while($row = mysql_fetch_array($q_pending1))
			{
				$q_search = "SELECT user_name,email,user_id FROM user_info WHERE id='$row[pending_user_id]'"; 
				$q_search1 = mysql_query($q_search) or die(mysql_error());
				$q_search2 = mysql_fetch_array($q_search1);
				//if($ro%2==0) 
				$s_id = $row['s_id'];
				$query = "frnd_id=".$row[pending_user_id]."&s_id=".$s_id;
				$dt=date("M d, H:iA", $row['req_date']);

				echo "<tr>";
				echo "<td><table width='100%' border='0'>
				  <tr> 
					<td height='65' rowspan='3' width='70'><div align='center'><img src='pic/images.jpg'/></div></td>
					<td width='200'>".mysql_result($q_search1,0,'user_name')."</td>
					<td rowspan='2' align='center'><a onClick=\"makeRequest3('add_frnds.php','running','$query');\" href='#'>Accept</a> | <a onClick=\"makeRequest3('invite_success.php','running','$query');\" href='#'>Reject</a></td>
				  </tr>............................................

 

it shows some friends requests...now if accept is click then

<a onClick=\"makeRequest3('add_frnds.php','running','$query');\" href='#'>Accept</a>

 

add_frnds.php runs

<?php
session_start();
if($_SESSION['normal_user'] !="")
{
	include("../dbconnect.php");
	$id_me = mysql_fetch_array(mysql_query("SELECT id FROM user_info WHERE user_id='$_SESSION[normal_user]'")) or die(mysql_error());
	$user_id = $id_me['id'];
	$tim = time();
	if($_GET['frnd_id']) $frnd_id = $_GET['frnd_id'];
	//echo $frnd_id;
	if($_GET['s_id']) $s_id = $_GET['s_id'];
	//echo $s_id;	
	$q_delete = "DELETE FROM frnd_pendinglist WHERE s_id='$s_id'";
	$q_detele1 = mysql_query($q_delete) or die(mysql_error());
	$q_add = "INSERT INTO frnd_list(user_id,frnd_id,create_date) VALUES('$user_id','$frnd_id','$tim')";
	$q_add1 = mysql_query($q_add) or die(mysql_error());
	$message = $frnd_id." is added to your friend list";
	echo $message;

}
?>

 

so the message is shows in the running div. the database is changed..the accepted friend id is added to the friend list and from the pending table the request deleted.

so now I want to reload the "req" div.

 

Link to comment
Share on other sites

Ok you'll have to add a tbody tag above the <tr> tag for each row, the tbody should have an id I would suggest something like "divreq_".$row[pending_user_id] which will give you a unique id

 

when you make the ajax request in that function change the display property of that div to none that will hide the div

 

hope its helpful

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.