PDA

View Full Version : Printing Data In a Loop


MrBojangle1
03-02-2003, 02:16 PM
Hey, I need some help. How would I go about printing data using a loop from a certain table? I think Mewtwo's Itemshop uses it, as an example.

Say this is my table structure:

ID(Primary Key) | name | image
1 | archer | archer.gif
2 | archmage | archmage.gif
3 | assasin | assasin.gif

How would I print that data in a loop? Then get it to display all the info? Any help would be appreciated. :dead:

mr e
03-02-2003, 08:42 PM
$getinfo = mysql_query("SELECT * FROM table");
while($info = mysql_fetch_array($getinfo)) {
print "$info[id] | $info[name] | $info[image]<br>";
}

MrBojangle1
03-03-2003, 04:59 PM
Thanks mr e! You seem to always be the solution to people's problems. ;)

mr e
03-04-2003, 12:48 AM
lol no problem :D

filburt1
03-04-2003, 01:33 PM
Just remember not to query in a loop. A few hacks do that and their authors should be smacked :)