Mateobus Posted April 25, 2006 Share Posted April 25, 2006 OK, I am trying to use php and javascript together and I have made more progress than I thought originally. The idea is that I want to have a delete option for some data in my mySQL database. IF the user clicks the delete link, it passes the ID to the confirmation(id) function. I have this working. Now I want to make the query that uses that ID, not as easy. Here is the code I have, anyone got the rest...function confirmation(id) { var answer = confirm("Delete data: "+id+"?") if (answer){ <?php $sql = "DELETE FROM table WHERE id='"; ?> //I want to say ID here... } } Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 Remember, PHP runs on the server and Javascript runs on the client. By the time the Javascript gets to put out the confirm message, PHP is long gone. What you may have to do is do some AJAX scripting to invoke a small PHP script sending it the ID to delete.Ken Quote Link to comment Share on other sites More sharing options...
Mateobus Posted April 25, 2006 Author Share Posted April 25, 2006 AJAX, i don't even know what that is... There has to be an easier way. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 25, 2006 Share Posted April 25, 2006 AJAX is the fancy new name given to Asynchronous Javascript. There is a sister site to this one named [a href=\"http://www.ajaxfreaks.com\" target=\"_blank\"]Ajaxfreaks[/a] where you can find out some more information.Actually AJAX isn't very hard to learn. And it makes possible the interaction that you want to do. Before people started exploring it, there was no way for Javascript to dynamically get results from a PHP script.Ken 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.