<?php
function get_user_id($username) {
return mysql_result(mysql_query("Select id From users Where username = '" . mysql_real_escape_string($username) . "'"), 0);
}
$sql = "select * from rating
WHERE user_id=" . get_user_id($myusername) . "
ORDER BY punkte ASC";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
$catid = $row['rating_id'];
$catname = $row['song_id'];
echo "<li id='item_$catid' class='ui-state-default'><span class='ui-icon ui-icon-arrowthick-2-n-s'></span>$catname</li>";
}
?>
UPDATE:
Sorry, I found the mistake, it was quite stupid:
$catid = $row['rating_id'];
$catname = $row['song_id'];
It should be:
$catid = $row['song_id'];
$catname = $row['song_name'];
So, thanks to all! As always: You can't figure it out before you post a question to Stackoverflow :)
For your new question, you can solve it with a inner join:
select s.song_name from rating r
inner join songs s on s.song_name_id = r.song_id
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