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 8658683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:49:45+00:00 2026-06-12T15:49:45+00:00

I have this problem that I have multiple fields that updates a database via

  • 0

I have this problem that I have multiple fields that updates a database via an AJAX-call. The AJAX call looks like this:

$(".fresheditable").fresheditor("save", function (id, parsedHtml) {
    $.ajax({
        url: 'save.php',
        type: 'POST',
        data: {
            id: id,
            parsedHtml: parsedHtml
        }
    });
});

The ID value changes depending on what element is being edited. The problem is when the update gets sent to the save.php document. How do I only run the update with the specific ID?

See my save.php:

if($_POST['id']='link') 
{
    $link = $_POST['parsedHtml']; //get posted data

    // query
    $sql = "UPDATE buttons SET linkname=? WHERE id=?";
    $q = $conn->prepare($sql);

    if ($q->execute(array($link,$_SESSION['button'])))
    {
        echo 1;
    }
}

//The next if-statement could look like this:

if($_POST['id']='contactperson') 
{
    $contactperson = $_POST['parsedHtml']; //get posted data

    // query
    $sql = "UPDATE buttons SET contactperson=? WHERE id=?";
    $q = $conn->prepare($sql);

    if ($q->execute(array($contactperson,$_SESSION['button'])))
    {
        echo 1;
    }
}

If more than one ID is sent to the save.php say link and contactperson both if-statements are true and the update sets the same values because the parsedHtml variable.

Is there anything I can do in save.php that can prevent this? Somehow I need to associate the correct parsedHtml with the corresponding id.

  • 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-06-12T15:49:46+00:00Added an answer on June 12, 2026 at 3:49 pm

    The comparison operator in PHP (as well as in Javascript) is == and not =

    if($_POST["id"]=="link")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem is this: I have multiple competing threads (100+) that need to access
I have this problem that my sites uses alot of ajax and when a
I have this problem that I can ref a button for control it. I
Ok I have this problem that I've never had before, it's really bugging me.
So we have this problem that we are trying to figure out. Heres what
I have this problem decomposing a relation schema into a set of schemas that
I have a problem that I can't resolve. Let's say I have this map
I have this annoying problem, that Im pretty sure happens to all of you
I have this little problem, that I cannot figure out which arguments to pass
I'm working on a problem that uses pointer arithmetic and I have found this

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.