Space_monkey Posted November 3, 2010 Share Posted November 3, 2010 Hi everyone, first time here! I am trying to use Jeditable. Not sure if anyone knows about it. http://www.appelsiini.net/projects/jeditable Basically its a Edit-in-place plugin for JQuery. However it requires a PHP script and Im pretty sure a mySQL db to work properly. I believe the PHP does something along the lines of taking the new inputted data, sending it to a db then echoing it back to where ever it came from, I think it achieves this using the $_POST function. This is exactly what I want! However this is the first time I have dealt with PHP. Im not too bad at Javascript but PHP is new to me. I have googled my brains out looking for an example php file for this but they don't seem to be around. I understand it cant just be written for me because it would be a different script for every one, and that's not what i want either. But some examples would be great ! The javascript i have so far is <html> <head> <style type="text/css"> a.test { font-weight: bold; } </style> <script type="text/javascript" src="jquery-1.4.3.min.js"></script> <script src="jquery.jeditable.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $('.edit').editable('http://Example.com/save.php', { indicator : 'Saving...', tooltip : 'Click to edit...' }); $('.edit_area').editable('http://Example.com/save.php', { type : 'textarea', cancel : 'Cancel', submit : 'OK', indicator : '<img src="img/indicator.gif">', tooltip : 'Click to edit...' }); }); </script> </head> <body> <div class="edit" id="div_1">Dolor</div> <div class="edit_area" id="div_2">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</div> <a href="http://jquery.com/">jQuery</a> </body> </html> Any help would be great! I think its at least mostly right so far but perhaps I'm missing something important which is why I cant get it all to come together. Quote Link to comment https://forums.phpfreaks.com/topic/217646-php-script-for-jeditable/ Share on other sites More sharing options...
trq Posted November 3, 2010 Share Posted November 3, 2010 There is a link in my signature to a free book (Hudzilla), it has entire chapters on handling forms (which is basically what ajax is) and using php with databases. Quote Link to comment https://forums.phpfreaks.com/topic/217646-php-script-for-jeditable/#findComment-1129860 Share on other sites More sharing options...
Space_monkey Posted November 3, 2010 Author Share Posted November 3, 2010 Well I had a read. It looks like an excellent resource so I bookmarked it haha. apart from that I didn't get much further. I gather I can use something along the lines of $con = mysql_connect("www.example.com","12345678","2653564"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Jeditable", $con); mysql_query("INSERT INTO jeditable (id, content) VALUES ('?something?', '?something?(maybe$_POST[div_1])')"); To connect to and select my database although past that I just used ?something? because I couldn't figure out what variables to use. then something along the lines of $_POST['div_1'] = str_replace("\n", "<br />", $_POST['div_1']); echo $_POST(div_1); to get the data and echo it back. although I'm pretty sure that echo function is wrong, not even sure how to use it yet. Got anymore hints? Im not even confident any of that made sense. I think this is a bit over my head to be honest, its a fair bit more complicated than the HTML and javascript im used to. Quote Link to comment https://forums.phpfreaks.com/topic/217646-php-script-for-jeditable/#findComment-1129906 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.