Jump to content

Checkbox values


NewbieAmi

Recommended Posts

?? Why do you loop thru the query results and place them in an array only to loop thru that array to output them? You could have saved yourself a lot of typing by just outputting the query result elements directly.

Hey,

i didnt see this post ... well as a newbie i thought it was a "good" practice. 

Link to comment
Share on other sites

^^^ if implemented without a lot of extra variables and unnecessary lines of code, this would be a programming practice called 'separation of concerns', which the OP will wish he was using when he finds out how much extra work it will be when using the mysqli extension with prepared queries and wants to switch to the much simpler php PDO extension.

 

if implemented by creating a bunch of extra variables and extra lines of code, it's a programming practice called 'wearing out your keyboard faster'  :happy-04:

I think i should learn OOP or use PDO. thks for the advice

Link to comment
Share on other sites

Yes - learn the pdo functions. It will be easy with just a bit of reading and using the examples that are shown in the manual. Use prepared queries too - the ones that use the colon-ized args and not the plain old question mark ones.

 

You should also tackle any kind of programming by stepping back from the keyboard and thinking clearly about what you are going to do. Write it down in steps. Then when you choose how to code it be sure you have READ the manual on each function to be sure you understand what it does and what it produces. If you had done that earlier you would have seen that you were simply moving one array (of query results) into another array.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.