I use this query to display a list of songs and show what songs have been clicked as a favorite by a user.
$query = mysql_query(
sprintf("
SELECT
s.*,
UNIX_TIMESTAMP(`date`) AS `date`,
f.userid as favoritehash
FROM
songs s
LEFT JOIN
favorites f
ON
f.favorite = s.id
AND f.userid = %s",
$userhash)
);
The songs
table is setup as: id artist title duration
etc. etc.
The favorites
table is setup as: id favorite userid
The userid
is a hashed value stored in a cookie to reference a unique user.
The query works fine but for some reason if I mark a song as a favorite in one browser. And then mark the same song as favorite in another browser to simulate multiple users the song will be displayed twice... once for each time it is marked favorite but the favorite indicator a <3 will still display correctly.
Any ideas?
Well got it to work via removign the sprintf() but curious to know why this is if anyone has any ideas.