简体   繁体   中英

ENUM checkbox update database

I have a field in a table called IsFlagged set as an ENUM with the values '0', '1'. I want it so that if the checkbox on the HTML form is ticked it updates the IsFlagged field with the number 1 to reflect this. How do I do it in the simplest way and what do I need to add to the form/PHP? Is ENUM the best way to do it?

Thanks.

a simple google search could not answer this question?

It's been answered before...

Update database with checkbox php mysql

Anyways more specifically - as you would not want to be sending requests back and forth to the database through the use of the check box, due to the overwhelming cost of transmission... Whatever project you're working on, if it's going across the web that is a lot of overhead to constantly send back and forth to the mySQL database across the internet, I could probably overflow the sql buffer by checking and un-checking the box a hundred times.

This signifies a need for further validation by the user and the developer, by making sure the user wants that selection before posting back to the database.

My suggestion is that you add a button to the bottom of the form that submits the check or unchecked portion of the query.

In this case, you would accept the check as a BOOLEAN operator as a parameter to your SQL prepared statement in the PHP...are you following?

To answer the php form - yes you would need it, if you are using php

for example

    <form method="post">
    <input type="checkbox" name="param[]" value="black" />
    <input type="submit" value="Submit" />
    </form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM