Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I have a php form in which I h

Status
Not open for further replies.

Dynamo3209

Programmer
Jan 2, 2003
57
US
Hi,
I have a php form in which I have to use checkboxes for some replies from the users and also have to update the records if a particular checkbox is checked/unchecked by the user.
I am using MySQL as the database with PHP.
Please let me know how to implement this in a php page.

Thanks,
Mohit
 
Create your input form. Take care to name all your fields.

Accept the input from that form. Keep in mind that checkboxes that are unchecked to not return a value.

Using string concatenation, create an update query based on the returned values.

Send that query to MySQL.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Maybe..

Retrieve the original data to be updated from the database..

Are the checkbox for accepting multiple values?

name the input for the checkbox example favefood[] for favorite foods checked.

Then loop through the result from the database and cross check with the value from

$favefood[$index]

Gotta be careful with the loop, it has to cover the total number of results and not cut the form value.

Actually the easiest would probably just delete everything and re enter the whole data into that particular table. So definitely the latest data will be entered. I do it this way so I don't have to check the values

eg.
Delete * from myfavefood where userid='$userid'

and then use loop to insert into myfavefood
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top