Jump to content

is using msql_fetch_array without a while loop possible?


tet3828

Recommended Posts

If someone would kindly take the time out to explain to me litterarly why the code below displays nothing...

 

$row = mysql_fetch_array($result);
echo "".$row['geoLoc']."<br>";

 

 

 

whereas this code shows my result ???

while($row = mysql_fetch_array($result)) {
echo "".$row['geoLoc']."<br>";
}

 

I'd be extremely thankful.

 

Just trying to grasp all these concepts.

Link to comment
Share on other sites

If you're grabbing data from a specific row of data, then you don't need a while loop.

 

If you're grabbing data from multiple rows, then you'll need a while loop as it will keep going through the data until there is nothing left for it to pull out.

 

Hope this helps!

Link to comment
Share on other sites

SELECT * FROM table_name WHERE id=3

 

Will only pull the record that has ID number 3, not the third row each time..

 

if you want to call upon the 3rd row everytime then

LIMIT 3,1

to your query should work may be wrong on the 3,1 part.. but the idea is to have it query the DB starting at the 3rd row and return 1 result

Link to comment
Share on other sites

No i understand the logic, I do the same thing myself as you mentioned.. it's just a thought though. I don't really know where I was going with my comment lol, was something that just poped into mind and I typed it out posted it prior to thinking logically about it. The only downside is if this person doesnt have ID's or ends up deleting the line with that ID for a new one.. Again I dunno where I was going with it though lol, didn't mean to come across as underminding.. just giving up an alternative in case he didnt have ID's i guess..

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.