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

Link to comment
Share on other sites

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.

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.