Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:00:37+00:00 2026-05-31T11:00:37+00:00

Alright. I’m new to jEditable. Let me explain the issue i’m having with jEditable.

  • 0

Alright. I’m new to jEditable. Let me explain the issue i’m having with jEditable.

I have this simple table in my database –

id  car        make 
1   panamera   porsche  
2   italia     ferraris 
3   avantador  lamborghini  
4   slk        mercedes

And i’m gonna echo this table in a while loop and below is the code –

<script type="text/javascript">
<?php
$query2 = "SELECT * FROM inplace LIMIT 0, 6";    
$result2 = mysql_query($query2) or die ('Query couldn\'t be executed');  
$row2 = mysql_fetch_assoc($result2);
?>

$(function() {
$(".items").editable("handler.php", { 
submitdata : {userid: "<?php echo $row2['id']; ?>"},
indicator : "<img src='img/indicator.gif'>",
tooltip   : "Doubleclick to edit...",
event     : "click",
onblur    : "submit",
name : 'newvalue',
id   : 'elementid',

}); 
});
</script>

</head>
<body>

<ul>
<?php  
$query = "SELECT * FROM inplace LIMIT 0, 6";    
$result = mysql_query($query) or die ('Query couldn\'t be executed');  
while ($row = mysql_fetch_assoc($result)) {

echo '<li class="items" id="car">'.$row['car'].'</li>';
echo '<li class="items" id="make">'.$row['make'].'</li>'; 
}

?>
</ul>

In the above code, i’m passing newvalue(user edited) and elementid(car or make) in the jeditable script. And i also need one more identifier which helps identify the correct database id to update. So i’m trying to pass the database id in submitdata : {userid: "<?php echo $row2['id']; ?>"}. I’m not sure if that method is correct.

And below is the update query in “handler.php” file –

require("db.php");

function fail($msg) {
header('HTTP/1.0 404 Not Found');
die($msg);
}

$id = (int)@$_POST['userid'];

$field = @$_POST['elementid'];

$allowed_fields = array('car','make');
if (!in_array($field, $allowed_fields)) fail('Invalid or missing field.', 404);
$newvalue =  $_POST['newvalue'];
$query = "UPDATE inplace SET `$field`='$newvalue' WHERE id=$id"; 
$result = mysql_query($query);
echo $newvalue;

So the issue here is, this submitdata : {userid: "<?php echo $row2['id']; ?>"} is passing only 1st id. That means its passing only one id. So even if you edit italia or avantador which belongs to ids 2 and 3 respectively, it updates 1st id. When i echo the query, whichever car you edit, it always reads as UPDATE inplace SETcar='volante' WHERE id=1. When i directly write 2 or 3 or 4 in the submitdata, it updates correctly. Its passing only one id. Someone suggested me to use like id="car-'.$row['id'].'" and then explode it and then use foo and stuff. I tried using it but didnt work for me. Looking for a solution for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:00:39+00:00Added an answer on May 31, 2026 at 11:00 am

    You can make a custom attribute in your <li> tags containing the id number. Then in your jQuery, you just grab that value.

    <script type="text/javascript">
    
    $(function() {
    
       $("li.items").each(function(index) {
    
          $(this).editable("handler.php", { 
             submitdata : {userid: $(this).attr('carid')},
             indicator : "<img src='img/indicator.gif'>",
             tooltip   : "Doubleclick to edit...",
             event     : "click",
             onblur    : "submit",
             name : 'newvalue',
             id   : 'elementid',
          });
    
       }); 
    
    });
    
    </script>
    
    </head>
    <body>
    
    <ul>
    
    <?php  
      $query = "SELECT * FROM inplace LIMIT 0, 6";    
      $result = mysql_query($query) or die ('Query couldn\'t be executed');  
      while ($row = mysql_fetch_assoc($result)) {
         echo '<li class="items" carid="'.$row['id'].'" id="car">'.$row['car'].'</li>';
         echo '<li class="items" carid="'.$row['id'].'" id="make">'.$row['make'].'</li>'; 
      }
    ?>
    
    </ul>
    

    Disclaimer: I didn’t test this and i’m not 100% sure on the jQuery syntax.

    [EDIT] I just changed it around to hopefully work using the $(this) selector to reference each specific <li>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright. So I have a table called contacts. In this table I have people
Alright, I have a table of tasks this table has a foreign key which
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Alright, i have read many different views on how to do this with no
Alright, I'm extremely new to programming so odds are this is a really easy
Alright so i have been working on this Dynamic load of a spinner from
Alright. I have several queries <?php // Make a MySQL Connection mysql_connect(mm.hostname.net, user, pass)
Alright guys, this should be a very simple request. I'd like to run a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.