I am looking for a example of a script to change data through a form.

I now can read a line with data from my (genealogy) database.
I have the following fields:
$id
$name
$iddad
$idmom

I have $id and $name filled and now want to do an update and change only the fields $iddad and $idmom.

But can someone help with an example to read the record and change 1 or 2 fields without changing or having to enter the other fields?

    UPDATE genealogy
    SET iddad = 4,
        idmom = 66
    WHERE id = 23;

    i had to make a few assumptions there:
    a.) all your data types are INTEGER
    b.) id is a key/unique
    c.) you are using an SQL-DBMS

    this would update the values for iddad to 4 and for idmom to 66, but only where the id = 23.

      thanks you assumptions are fine.
      But how can i combine this with a form or so?
      I want to ask for id 23 and then through a kind of form change the data in to a database.

        I think I found an alternative, but still can't figure it out.

        $sql1 = "UPDATE genealogy SET iddad='$ziddad' WHERE id = '$zid'";

        An echo would result in : iddad = 5 and id = 1, which is correct.

        However the table genealogy is not updated.
        I have 2 databases open, is it possible that is tries to connect to the wrong database?
        Can I add a function to go to the right database?

          can you post the code you are writing? its really just stabbing in the dark otherwise.

            Resolved, on internet I found that I had to use
            mysql_select_db("dbname") or die ;

              Write a Reply...