I have the following table:
CREATE TABLE IF NOT EXISTS `notes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`note` text,
PRIMARY KEY (`id`)
)
INSERT INTO `notes` (`id`, `uid`, `note`) VALUES
(1, 1, 'noteteeext'),
(2, 1, 'notenotenotenote');
As you can see i have 2 rows with uid=1 but it only returns 1 row! (the second one)
$sql = "SELECT id,uid,note
FROM notes
WHERE uid = 1";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
echo $row['note'];
}
What's wrong? :/
Are you sure there definitely isn't a $row = mysql_fetch_assoc($result) prior to the while loop in the actualy code you are running?
Obviously this is not the problem if the code you have posted above is exactly what you are running, but this would be the most common cause of this behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With