Jump to content

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. 

^^^ 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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.