[PHP MySQL] Looping through the rows..

SineCosine

I'm still looking for my Tangent
Reaction score
77
Yea..
How would I loop through a mysql_fetch_array(Resource)?

Like,
Code:
while (Rows?) {

    //Do Stuff
}

But that would go on forever.. Wouldn't it?
How do I make it perform an action for every row?
Like, retrieve a value and display it for each row it encounters till the end.

I can't think of anything =x
 

Im_On_56k

Hm...
Reaction score
116
Code:
$query = "SELECT * FROM mytable";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
    echo $row['info'];
}

You mean like this? Assuming you have a field called info this will display the contents of info for every row it loops through.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
OMG!
Thanks :D

Guess what I did wrong?
I used:
Code:
while($row [B]==[/B] mysql_fetch_array($result)) {
    echo $row['info'];
}

Two 'equal' signs =/
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top