-
While loop problem
I have checked and checked so many times and i can't see why this is happening!
PHP Code:
$skin = mysql_query( "SELECT id,path,name,description,author FROM skins ORDER BY id ASC LIMIT 10" );
PHP Code:
while( $list = mysql_fetch_array( $skin ) )
{
echo "variables and stuff";
}
Now technically speaking it should display what i want in the while loop 10 times in an ascending order. However i have 3 rows in the table and it is currently displaying 2 / 3.
So the latest entry is being missed out for some reason and i can't work out why this is :S
-
Can't see why it's happening, are you actually echoing the loop variable?
-
yes i am. Stuff like:
PHP Code:
echo $list[ 'name' ]
$list[ 'path' ]
$list[ 'description' ]
$list[ 'author' ];
It works for 2 of the entries but as i said the latest entry doesn't show.
-
I had this problem when I was making a private messaging system, can't for the life of me remember how I fixed it though.. I suggest you just go over your code, checking all the obvious things, or maybe try a new way of displaying it, sorry I couldn't be of much more help.
-
Check your PMA for db entries?
-
PHP Code:
while( $list = mysql_fetch_assoc( $skin ) )
{
echo "variables and stuff";
}
I think
-
well actually i did try that with:
PHP Code:
while( $list = mysql_fetch_array( $skin, MYSQL_ASSOC ) )
{
echo "variables and stuff";
}
But still did the same thing
-
-
the table for skins is:
Code:
id path name description author
1 default Default default skin me
2 dark dark skin Dark skin me
3 light light skin Light skin me
-
Try this, probably wrong.
PHP Code:
$skin = mysql_query( "SELECT * FROM `skins` ORDER BY `id` ASC LIMIT 10" );
while( $data = mysql_fetch_array( $skin ) {
echo $data['description'];
}
You get the idea