Jump to content

I'VE GOT A GOOD CHALLENGE FOR YOU PHP GRAND MASTERS!!!


Freedom-n-Democrazy

Recommended Posts

LOL note the topic is a pun at Help Vampires... I actually have an unchallenging question.

 

I'm trying to echo out a column in a MySQL table. I'm getting one field echoing, but not the others:

I'm using this code style, but I've made a small mistake somewhere at the end, I've tried many combinations trying to fix it, but haven't succeeded..

$query = "select email from newsletters"; $result = mysql_query($query); $row = mysql_fetch_array($result); foreach ($row as $email) {echo $email;}

I got the argument foreach() straight out of the manual and copied the syntax style exactly as was demonstrated in the example, but its still not working. What have I done wrong?

Link to comment
Share on other sites

The fetch function, and the the foreach() loop need to be within a while loop. The foreach loop will only iterate over the array of the one returned record.

 

This thread is be solved, but I would like to know what "iterate over the array" means in English. Can someone please explain?

I ask because although I can see how the solution worked for my issue, 'iterating' may apply to future PHP functions, and I don't know when the word should be used.. so hopefully in street- talk will help me understand better. ;)

Link to comment
Share on other sites

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.