query problems

So for some, probably very obvious reason, this is only giving me the first result from the database even though there are more that meet the criteria. Could someone please tell me what I’m doing wrong. I know it must be something simple but I’m totally stumped.

[php] $query1 = "SELECT interest FROM interests WHERE profileid = '{$profileid}' "; $result1 = mysql_query($query1, $connection) or die(mysql_error()); $savedinterests = mysql_fetch_assoc($result1); print_r($savedinterests); [/php]

Try removing the curly brackets in this query: [php]WHERE profileid = ‘{$profileid}’[/php]

It should be [php] WHERE profileid = ‘$profileid’[/php]

If that doesn’t do the trick I would add a WHILE loop.

[php]
$query1 = "SELECT interest
FROM interests
WHERE profileid = ‘{$profileid}’
";
$result1 = mysql_query($query1, $connection) or die(mysql_error());

WHILE ($savedinterests = mysql_fetch_assoc($result1)){
print $savedinterests;
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service