How do I store which of the php checkboxes are checked into the database. What kind of field do I need to create in the database table. All my text fields are Varchar. I was thinking maybe bit?
In your specific case an SET with values 'salon','mobile','student','other' sounds appropriate to store all four checkbox values in a single database field.
Then again, I suspect that you really want to use radiobuttons rather than checkboxes (in that case use ENUM instead of SET).
In both cases you have to use the correct insert syntax for the field type of course, but the advantage over a bit is that you can use meaningful content directly generated from the business_type[] array
It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.
Are you able to show me an example? I'm new to this.
Enterint the above code did nothing to the database. Isn't that because a VARCHAR field is purely for storing text? Please feel free to tell me i'm talking rubbish lol.
I would create four columns of type VARCHAR. I would put the values from the checkboxes into these columns. That way your data base table will be easier to read. If you use separate columns, it will be easy to add more definitions (with ALTER TABLE) and all your existing queries will still work after you do that.
You definitely need to learn about this PHP function. While the comment from thehagman at ID: 38001662 is not really applicable (MySQL_Query() will not run more than one query) it is still a good practice to filter and escape your external data. http://php.net/manual/en/function.mysql-real-escape-string.php
You also need to learn about this function. MySQL is not a black box; it can and will fail, sometimes for reasons outside of your control. So you must test the return values from its functions and (immediately) visualize the error information. http://php.net/manual/en/function.mysql-error.php
Please tell us what you expected and why you didn't respond if you thought our posts did not have enough information for your needs. thanks, ~Ray
Not the solution you were looking for?
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.
Premium Content
You need an Expert Office subscription to comment.Start Free Trial