Jump to content

Approving Entries Submitted To Database


olilish

Recommended Posts

Hello, I have a simple contact form that adds an entry to my mysql database.I would like my website to only display 'approved' entrys. I need my client to access all entrys in the database and then choose to approve, edit or delete them.I have figured out the editing and deletion part. So, my question what is the best way to have an entry approved?My initial thought is that I could have a field in my table that is simply 'true' or 'false'? - and therefore my website could display only 'true' records in my table.If this is correct, it would be great if someone could give me a place to start!Thanks!

Link to comment
Share on other sites

Don't sweat the type. I can only guess what goes on internally, but almost no one messes with individual bits anymore. It's only efficient if you're using enough bit flags to fill a whole byte. If MySql does have a Boolean type, it's probably just for convenience. Most systems these days use a whole byte or even a whole native word (up to 64 bits) to store a Boolean. The data pointer alone is going to use up 64 bits just to store the address of the value. So what's the virtue in saving 7 bits or 63 bits in the place the pointer points to? And what would you do with the other 7 or 63 bits?Maybe the chip in your HVAC thermostat conserves memory like that, but it seems pretty old fashioned for a big old server.

Link to comment
Share on other sites

Ok, so would I need to have every entry submitted include an integer of 0 and have my clients admin show records WHERE "approved" = 0.I would then need to have my client 'approve' an entry by editing my "approved" field to 1.Then in the main webstie I would only display entries WHERE "approved" = 1.Does that sound correct?

Link to comment
Share on other sites

For other similar situations where you have a limited number of possible values, an enum field comes in pretty handy. If you have a field that could have one of, for example, four values (like User, Guest, Moderator, Admin), you could use an enum field and list those four values as choices. An enum would be more efficient than a varchar field because instead of storing one or more bytes per character it would only store an integer that would point internally to the value you picked, sort of like an array of values where you store the array index instead of the actual value. So you could also use an enum field to store true/false, and it would basically work the same as an int field internally.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...