Allows just state that I've some (several many) text fields on the page... and that i enter a brand new value in one of these, then click a control button... How do i update the database with only that new value? Or, if it might be simpler... How do i update all individuals textfields towards the database?

Thanks :)

you should use jquery data(), to keep the very first condition ,

when you wish to publish it, publish just the textbox that's been transformed .

check this out post

<?php
$sql = "UPDATE table_name SET";
foreach($_POST as $key=>$value){
    if($key != 'submit'){
        $sql .= " " . $key . " = '" . $value . "'";
    }
}
$sql = " WHERE ......";
?>

This can create the sql statement for you personally. You need to simply include security and so the execution.

To update everything:

You are able to organize your inputs such as this (1,2,3,4 - are record id's in database):

<input type="text" name="info[1]" value="blabla">
<input type="text" name="info[2]" value="blabla">
<input type="text" name="info[3]" value="blabla">
<input type="text" name="info[4]" value="blabla">
<!-- ... -->

Then, inside your PHP script:

<?php
foreach($_POST['info'] as $id=>$data){
    mysql_query("UPDATE table SET data = '".mysql_escape_string($data)."' WHERE id = ".intval($id));
}
?>

By doing this you will see one UPDATE statement for each record

To update only individuals that transformed:

You should use javascript's onChange() event to determine what fields were transformed and submit only individuals. You need to be carefull, if your user has javascript disabled, he well never have the ability to change any record.

identify textfield values: every textfield should really possess a "title" attribute:

 <input type="text" name="firstName" value="please enter your first name"/>

you are able to the access the need for the textfield "foo" with $_Publish["foo"] To understand when the area was transformed you have to compare it using the default value.

if($_POST["firstName"]!="please enter your first name"){
   /*do databse update*/
}

Exactly how you need to do the database update is dependent in your application.

As I can tell this, it's two approaches

1 - Once you clicks the save button, you collect all of the values for an array (Using javascrip) and pass that array (Like a comma separated list or something like that) towards the server. there in the transaction block you remove all of the existing values in the table and place the brand new values.

2 - But When there are many, many text values, possess a javascript to recognize the altering text boxes only.

simple procedure could be,

  • choose a text area

    get its value to some variable

    when user does a big change towards the text area always match up against the original value

    When the value transformed, flag that text box

    when user clicks 'save' get just the transformed value fields

cheers

sameera