doddsey_65 Posted November 3, 2010 Share Posted November 3, 2010 i am making a private messaging system like hotmails where the message list appears on the left. Then when you click on one of them the box on the right loads the email. The problem is i dont really know how to go about it. Anyone have any pointers? Quote Link to comment https://forums.phpfreaks.com/topic/217680-message-system/ Share on other sites More sharing options...
inversesoft123 Posted November 3, 2010 Share Posted November 3, 2010 Interested to know how did you solved this Quote Link to comment https://forums.phpfreaks.com/topic/217680-message-system/#findComment-1129975 Share on other sites More sharing options...
Twitch Posted November 3, 2010 Share Posted November 3, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/217680-message-system/#findComment-1129982 Share on other sites More sharing options...
doddsey_65 Posted November 4, 2010 Author Share Posted November 4, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/217680-message-system/#findComment-1130272 Share on other sites More sharing options...
Twitch Posted November 8, 2010 Share Posted November 8, 2010 Sorry for the delay in response. Was in Houston watching my Texans blow another game...haha Only difference in your code and mine is that I wrote too much code...haha Quote Link to comment https://forums.phpfreaks.com/topic/217680-message-system/#findComment-1131800 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.