Jump to content


Photo

qns abt mysql functions


  • Please log in to reply
2 replies to this topic

#1 aaronlzw_21

aaronlzw_21
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 16 May 2006 - 07:04 AM

i have a qns.. is there a mysql function that takes out the whole table and store it in a variable. and from there we access it? like in asp.net there is.

and another qns is that lets say a for loop that loop 3 times. how do i halt it till a user clicks on something update the database then loop the second time and same thing happen, halt, click then loop again. is there a fuction?

thanks ya..

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 16 May 2006 - 08:41 AM

You can fetch all of a tables data and loop through it with something like:
<?php
$result = mysql_query("SELECT * FROM `table`");
while($row = mysql_fetch_assoc($result)) {
    //Echo your columns here with $row['name'] to print the column 'name'
}
?>

You won't be able to do your second question as easily with PHP - Everything is processed on the server before it is passed to the users browser. You'll have to pass a count to and from your page to keep track of cycles and clicks.

#3 aaronlzw_21

aaronlzw_21
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 16 May 2006 - 08:55 AM

[!--quoteo(post=374223:date=May 16 2006, 04:41 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 16 2006, 04:41 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You can fetch all of a tables data and loop through it with something like:
<?php
$result = mysql_query("SELECT * FROM `table`");
while($row = mysql_fetch_assoc($result)) {
    //Echo your columns here with $row['name'] to print the column 'name'
}
?>

You won't be able to do your second question as easily with PHP - Everything is processed on the server before it is passed to the users browser. You'll have to pass a count to and from your page to keep track of cycles and clicks.
[/quote]


okok thanks.. what's the differences between mysql_fetch_assoc(), mysql_fetch_row() and mysql_fetch_array()? they all seem to work the same way..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users