Basic Database Question

I have a Database with 4 columns. FirstName, LastName, Age, and FNID.

FNID is always defaulted with the value ‘1’.

How do I go about creating a button that when clicked adds 1 (+1) to the FNID value?

Basically a button that changes the FNID of an entry to ‘2’ instead of ‘1’.

Cheers,
Kevin

Well, you just execute a SQL to do this.

The button can call another PHP page that executes the SQL or you could use Javascript/Jquery to do it.

Basically, you would use a SQL command something like this: (Not tested, just general use!)

$query=“UPDATE table_name SET FNID = FNID + 1 WHERE FirstName=$firstname and LastName=$lastname”;

You didn’t show any code, so not sure how you are handling the selection of the record you want to change.
But, a SQL “UPDATE” command will update an existing record based on the WHERE data you selected…

Should work, good luck…

Sponsor our Newsletter | Privacy Policy | Terms of Service