murhapuro Posted January 14, 2008 Share Posted January 14, 2008 Hello I have this problem that i have this ajax rating script that shows the users how good something is rated, they can also vote by mouseovering it. I call the rating bar with : <?php echo rating_bar('page-id-is-in-here','5'); ?> Now i would like to get that page id from other table in the same database. This would help me alot cause i have many pages to make. I tried to call it like this: <?php $result = mysql_query("SELECT stars_ss FROM info WHERE (id ='$id');", $connection); while ($row = mysql_fetch_array($result)) { echo rating_bar('stars_ss','5'); } ?> This however did not work, and i would like to solve this before i go any further. I have 2 tables: info (in here is the stars_ss) ratings (here is all the ratings) Could anyone please suggest how i would make this work? Im very new to php, but would like to learn more! Thanks in advance! Murhapuro Link to comment https://forums.phpfreaks.com/topic/85985-problem-with-php-im-new-to-php-so-this-is-prolly-easy-for-pros/ Share on other sites More sharing options...
nikefido Posted January 14, 2008 Share Posted January 14, 2008 you're while loop looks wrong to me. while ($row = mysql_fetch_array($result)) { echo rating_bar('$row['column_name']','5'); } Insert the appropriate column name into this part: $row['column_name']. Also, are you getting any errors? I would set it up like this: <?php $query = "SELECT stars_ss FROM info WHERE (id ='$id');"; $result = mysql_query($query, $connection) or die("Error: " . mysql_error()); while ($row = mysql_fetch_array($result)) { echo rating_bar($row['column_name'],'5'); } ?> Link to comment https://forums.phpfreaks.com/topic/85985-problem-with-php-im-new-to-php-so-this-is-prolly-easy-for-pros/#findComment-439103 Share on other sites More sharing options...
murhapuro Posted January 15, 2008 Author Share Posted January 15, 2008 Thank you very much! That worked like a charm! Now i will try to make the php to count 3 different ratings and create one main rating! Thank you for help! Murhapuro Link to comment https://forums.phpfreaks.com/topic/85985-problem-with-php-im-new-to-php-so-this-is-prolly-easy-for-pros/#findComment-439715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.