Jump to content

message system


doddsey_65

Recommended Posts

I would create a list of emails from a recordset by looping through them and when one is clicked on use jquery by using the javascript below.  http://jquery.com/  and you can get a loading.gif here http://www.ajaxload.info/ 

<script type="text/javascript">
//jquery ajax

$(function() {
$(".yourTrigger").click(function() {
$("#yourDisplayDiv").html("<img src='images/loading.gif' width='28' height='28' align='absmiddle'/> Loading...");
var id = $(this).attr("id");//get id of clicked
var string = 'id='+ id ;
$.ajax({
   type: "POST",
   url: "details.php",
   data: string,
   cache: false,

   success: function(html){
   $("#yourDisplayDiv").html(html);	

  }
   
});

return false;
});
});
//end jquery ajax
</script>

 

and in the details.php file...

 

<?php
DATABASE CONNECTIONS HERE
// Retrieve data from Query String
$detail=$_POST["id"];

// Escape User Input to help prevent SQL Injection
$detail = mysql_real_escape_string($detail);

//build query
$query = "SELECT * FROM your_table WHERE id = '$detail'";

//Execute query
$qry_result = mysql_query($query) or die(mysql_error());


// Insert a new row in the table for each favorite returned
while($row = mysql_fetch_array($qry_result)){

echo some sort of string;
?>

 

 

Not sure if all this code is accurate but it should get you started. 

 

-Twitch

 

Link to comment
Share on other sites

thanks twitch. I did in the end use jquery. I did find some scripts that did it for me but jquery was the better choice. I do have an offtopic question regarding your code though.

 

at the beginning you add:

 

$detail=$_POST["id"];
$detail = mysql_real_escape_string($detail);

 

but i would use:

 

$detail = mysql_real_escape_string($_POST["id"]);

 

is there any difference? I dont think there would be but you never know.

 

Also where you use:

 

$query = "SELECT * FROM your_table WHERE id = '$detail'";
$qry_result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($qry_result)){

 

i would use:

 

$query = mysql_query("SELECT * FROM your_table WHERE id = '$detail'")
or die(mysql_error());
while($row = mysql_fetch_array($query )){

 

Like i said just interested to know if there is any difference.

 

Thanks

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.