• Editing Flags by an HTML form
    4 replies, posted
I'm using flags in PHP to toggle things on or off in my database - say to set a user as banned or admin, or to make a post hidden or stickied. Do any of you know of any way to make this into a bunch of options on a web page easily? I know I could put a bunch of checkboxes and work through each one on the server side, but that could be difficult, especially with a large number of options. I'm sure other sites must have found solutions to this problem, or found ways to work around it. I'd rather not find an alternative method to using flags, as they're fantastically easy to use and great for efficient storage in a database. If worst comes to worst, I'll just end up putting a bunch of checkboxes on the page and having to deal with that. I'm not sure what the best approach to dealing with it would be, either - I'm thinking using javascript to pop up a window with a list of checkboxes, the user picks what they want then click okay... but then I'm not sure how it would work from there. It'd also force users to have javascript enabled, which they may not all have (though unlikely). Have any of you had to deal with this kind of thing before, or come across potential solutions?
OK, first of all, "flags"? That sounds like a name you came up with for a field in a database. Secondly, if you want to edit a database using HTML or JS, here's what you have to do. [list] [*]Step away from the monitor [*]Slap yourself [*]Read a tutorial on how web development works. [/list] HTML and JS are clientside. The database is serverside. Obviously editing something serverside would require something which is serverside as well. Like PHP. [editline]08:09PM[/editline] You should also learn to be more coherent as I barely understood any of your post.
[QUOTE=Dusty_;21292915]OK, first of all, "flags"? That sounds like a name you came up with for a field in a database.[/QUOTE] Well, first of all, flags are just you playing with the bits in a type. That's basically it. So if you've got a byte, you've got 8 bits. That's 8 flags to work with. You just do bitwise operations on them (that is, bitwise OR, bitwise AND and so on and so forth) to flip the bits on and off and check for values. I'm surprised you haven't heard of them before, if you've done any programming - even if you haven't used them yourself you're very likely to have used them in the process of coding it. Here's an example of some flags being set: [code] file.open(filename.c_str(), [b]std::ios::in | std::ios::binary[/b]); // or sf::RenderWindow rw(vm, "title", [b]sf::Style::Titlebar | sf::Style::Close[/b]); [/code] [url=http://stackoverflow.com/questions/224799/bitwise-flags-abandoned]There's a small discussion on them here[/url]. [QUOTE=Dusty_;21292915]Secondly, if you want to edit a database using HTML or JS, here's what you have to do. [list] [*]Step away from the monitor [*]Slap yourself [*]Read a tutorial on how web development works. [/list] HTML and JS are clientside. The database is serverside. Obviously editing something serverside would require something which is serverside as well. Like PHP.[/QUOTE] Yes. I am well aware of this. I may not have [i]explicitly[/i] stated in my first post that I would be using PHP to alter the data to put into the database (even though I did, and made inferences to it), but I thought that it was blindingly obvious enough, especially given I'd made explicit reference to PHP in the first sentence. I'm not running static HTML here, so to presume I am or and insinuate that I am trying to edit a database by using javascript from the clientside is ridiculous. Obviously there would be PHP on the server side controlling everything, but I'm looking for the best implementation on the client side to work with [i]first[/i], which should then make it easier for me to develop the rest in the backend. [QUOTE=Dusty_;21292915]You should also learn to be more coherent as I barely understood any of your post.[/QUOTE] I thought my post [i]was[/i] coherent. Even if it was incoherent, at least it was well-structured, which is more than I can say for some of the other posts on this forum. If there were any particular parts of the post you found [b]more[/b] 'incoherent' than others, you could easily have quoted that into the post so I could then clarify it for you. As it stands I still see no issue with my original post. [editline]10:00AM[/editline] Here's me making explicit reference to PHP: [QUOTE=mechanarchy;21287533]I'm using flags in PHP[/QUOTE] First five words.
[QUOTE=mechanarchy;21297733]Well, first of all, flags are just you playing with the bits in a type. That's basically it. So if you've got a byte, you've got 8 bits. That's 8 flags to work with. You just do bitwise operations on them (that is, bitwise OR, bitwise AND and so on and so forth) to flip the bits on and off and check for values. I'm surprised you haven't heard of them before, if you've done any programming - even if you haven't used them yourself you're very likely to have used them in the process of coding it. Here's an example of some flags being set: [code] file.open(filename.c_str(), [b]std::ios::in | std::ios::binary[/b]); // or sf::RenderWindow rw(vm, "title", [b]sf::Style::Titlebar | sf::Style::Close[/b]); [/code] [url=http://stackoverflow.com/questions/224799/bitwise-flags-abandoned]There's a small discussion on them here[/url].[/QUOTE] ohhhhhhhhhhhhhhhhhhhhhhhhhh those. my bad. [quote] rest of post [/quote] ok so what's the problem? as far as I understood you're editing the database with php and want to edit it with html.
[QUOTE=Dusty_;21298039]ok so what's the problem? as far as I understood you're editing the database with php and want to edit it with html.[/QUOTE] That's the idea. So, like I said, I'm looking for the best way to provide options in the HTML so then I can put that into the database through PHP.
Sorry, you need to Log In to post a reply to this thread.