almightyegg Posted June 27, 2007 Share Posted June 27, 2007 I have a message board that is run my certain selected members. These members can Pin items, Lock them and Delete them. Is there any way you can click the link that says 'Lock this thread', 'Delete this thread' or 'Pin/Unpin this thread' and it will perform the action without reloading the page??? For instance I would click the delete button and it would delete the infomation from the MySQL database but the information would still be on the screen because it wouldn't have reloaded. Same with if I clicked the link that Locked/Pinned it, it would edit the column in the appropriate row that said No, to Yes meaning it would now be Locked/Pinned. I'm assuming that if this can be done, it won't be using PHP directly??? Quote Link to comment Share on other sites More sharing options...
bbaker Posted June 27, 2007 Share Posted June 27, 2007 AJAX Quote Link to comment Share on other sites More sharing options...
almightyegg Posted June 27, 2007 Author Share Posted June 27, 2007 Can you suggest any good sites that would show me how to do this?? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted June 27, 2007 Share Posted June 27, 2007 You can use PHP, but you use AJAX, and other javascript methods to carry out that PHP. I would reccomend using: http://www.tizag.com/ajaxTutorial/ to learn AJAX, it got me started, an it really works well. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted June 27, 2007 Author Share Posted June 27, 2007 I didn't follow it at all really...what's the point of the browser code?? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted June 27, 2007 Share Posted June 27, 2007 all AJAX is, is javascript It allows you to retrieve information from the server, HTML or PHP (and other files), then it processes them, and returns your results, then you use JavaScript to decide on what to do with those results. Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 27, 2007 Share Posted June 27, 2007 why use ajax when a simple get and refresh via a header statement would work. this example would work on all links ok. <?php session_start(); //database connetion $query="SELECT from `message` where `message_id`='$message_id' and `id`='$id'"; $result=mysql_query($query); while($x=mysql_fetch_assoc($result)){ //relly encrypt this and unencript ok. echo"<a href=''".$_SERVER["PHP_SELF"]."'?message=delete&id=$id&message_id=$message_id'>Delete Message</a>"; if($_GET['message']=="delete"){ $id=$_POST['id']; $message_id=$_POST['message_id']; $query2="DELETE from `message` where `message_id`='$message_id' and `id`='$id'"; $result2=mysql_query($query2); if(mysql_affected_rows($result2)){ header("location ".$_SERVER['PHP_SELF']." "); } } } ?> example 2 no refresh needed ok. topic.php <?php //database connetion $query="select from message where message_id='$message_id'"; $result=mysql_query($query); while($x=mysql_fetch_assoc($result)){ echo $x['message']; echo"<p><p/>"; echo"<a href='delete.php?cmd=delete&message_id=$message_id'>Delete Message</a>"; } ?> delete.php <?php session_start(); if($_GET['cmd']=="delete"){ $message_id=$_POST($_GET['message_id']); $query2="DELETE from message where message_id='$message_id' "; $result2=mysql_query($query2) or die("mysql_error()"); if(mysql_affected_rows($result2)){ header("location topic_page.php?message_id=$message_id"); } } } ?> Quote Link to comment Share on other sites More sharing options...
almightyegg Posted June 27, 2007 Author Share Posted June 27, 2007 why use ajax when a simple get and refresh via a header statement would work. I tried your second example, perhaps I entered it all wrong but it came up with many errors that seemed to do with the structure of the code rather than the variables... all AJAX is, is javascript It allows you to retrieve information from the server, HTML or PHP (and other files), then it processes them, and returns your results, then you use JavaScript to decide on what to do with those results. So does this mean I 100% need to know javascript?? Quote Link to comment 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.