moon 111 Posted April 17, 2008 Share Posted April 17, 2008 My query is this: SELECT AVG(rating) FROM rating WHERE sid = '34' LIMIT 1 And my code: <?php $q = "SELECT AVG(rating) FROM rating WHERE sid = '34' LIMIT 1"; $r = mysql_query($q); $rating = mysql_fetch_array($r); $rating = $rating['AVG(rating)']; // How can I do this correctly? ?> How do I access the result? Thanks Link to comment https://forums.phpfreaks.com/topic/101505-how-do-i-access-the-result-of-this-query/ Share on other sites More sharing options...
awpti Posted April 17, 2008 Share Posted April 17, 2008 $q = "SELECT AVG(rating) AS rating FROM rating WHERE sid = '34' LIMIT 1" $r = mysql_query($q); $rating = mysql_fetch_array($r); echo $rating['rating']; // How can I do this correctly? Link to comment https://forums.phpfreaks.com/topic/101505-how-do-i-access-the-result-of-this-query/#findComment-519211 Share on other sites More sharing options...
moon 111 Posted April 17, 2008 Author Share Posted April 17, 2008 Thanks! Link to comment https://forums.phpfreaks.com/topic/101505-how-do-i-access-the-result-of-this-query/#findComment-519218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.