Jump to content

PHP Script for Jeditable


Space_monkey

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.