jayjay159 Posted May 12, 2011 Share Posted May 12, 2011 Okay so i'm making an inbox system with jQuery but i can't get it to work, basically i want the user to click on a link and jQuery will send get data to read.php, i will post both of the pages of code! Thanks All! Inbox Page. <?php session_start(); ?> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type='text/javascript'> function doVar() { $.get('read.php', {messageid: $('#in').val()}, function(output){ $('#read').html(output).slideToggle(500); } ); } </script> <div id="inbox_wrap"> <?php $_SESSION['username'] = "Jamie@jaynet.home"; $user = $_SESSION['username']; require("connect.php"); //$id = mysql_query("SELECT id FROM mail WHERE to_name = '$user' ORDER BY id DESC") or die (mysql_error()); $inbox = mysql_query("SELECT * FROM mail WHERE to_name = '$user' ORDER BY id DESC") or die (mysql_error()); $num_msg = mysql_num_rows($inbox); if($num_msg==0) {echo "You have no messages";} for($count = 1; $count <= $num_msg; $count++) { $row = mysql_fetch_array($inbox); $idi = $row['id']; $read = $row['read_yn']; $from = $row['from_name']; $input = "<a href='#' id='in' onClick='doVar();' />";//need to send a value or something have tried <input type='text' value='$idi' /> doesn't work echo $input; if($read==0) echo "New!"; } ?> </div> <div id='read'></div> Read Page. <?php session_start(); $_SESSION['username'] = "Jamie@jaynet.home"; $user = $_SESSION['username']; $messageid = $_GET['messageid']; require("connect.php"); mysql_query("UPDATE mail SET read_yn='1' WHERE id='$messageid'")or die(mysql_error()); $gm = mysql_query("SELECT * FROM mail WHERE id = '$messageid' AND to_name = '$user'") or die(mysql_error()); $gmr = mysql_fetch_assoc($gm); $to = $gmr['to_name']; $from = $gmr['from_name']; $message = $gmr['message']; $read = $gmr['read_yn']; echo "To: ".$to."<br />"."From: ".$from."<br />"."Message: <br />".$message; mysql_close(); if($_POST['delete']) { require("connect.php"); mysql_query("DELETE FROM mail WHERE id = '$messageid'")or die(mysql_error()); mysql_close(); echo "<meta http-equiv='refresh' content='0;url=index.php?page=inbox'"; } ?> <form method='POST'> <input type='submit' name='delete' value='Delete' /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/236252-how-to-jquery-inbox-system/ Share on other sites More sharing options...
Maq Posted May 12, 2011 Share Posted May 12, 2011 In the future, please place tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/236252-how-to-jquery-inbox-system/#findComment-1214644 Share on other sites More sharing options...
jayjay159 Posted May 12, 2011 Author Share Posted May 12, 2011 Sorry i'm new on here didn't no i had to. Quote Link to comment https://forums.phpfreaks.com/topic/236252-how-to-jquery-inbox-system/#findComment-1214650 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.