Jump to content

[SOLVED] Getting 61 rows in a table and getting them all.


Twister1004

Recommended Posts

Hey, another crises im facing.

 

Objective: I have about 61 songs in my database and I want it to come out in the form of a TABLE. However, I keep getting massive errors, and I don't understand how to fix it. It could be because im not experienced enough and never delt with it.

 

Error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\XAMPP\xampp\htdocs\songs.php on line 38

 

It also just keeps on going on and on acting like the Loop will never end.

 

code:

$sel = 'SELECT DISTINCT `id`, `song`, `artist` FROM `music`';
$sel2 = mysql_query($sel) or die("WTH! " . mysql_error());
$get = mysql_fetch_row($sel2);
while (mysql_num_rows($get) <= 61){
++$get;
echo "<table><tr><td>" . $get[0] . "</td><td> " . $get[1] . "</td><td> " . $get[2] . "</td></tr></table>";
}

 

Any hints tips posts (You know the drill) Thanks =D

instead of explaining what you did wrong, i just fixed it...

 

$sel = 'SELECT * FROM `music`';
$sel2 = mysql_query($sel) or die("WTH! " . mysql_error());

while ($get = mysql_fetch_array($sel2)){
     echo "<table><tr><td>" . $get[0] . "</td><td> " . $get[1] . "</td><td> " . $get[2] . "</td></tr></table>";
}

 

Hope that helps, i am to tired to write out an explanation.

NEVER MIND! I just realized you made a variable inside the while statement O_o. Didn't know that was possible.

 

Edit2: Is there any way where I can make it into a table when it gets it out of the database?

 

Also thank you dclamp.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.