Copilot 🤖 Posted July 9, 2008 Share Posted July 9, 2008 When the poster has no votes, it will show the appropriate message. If they have one vote, the result will not show. If they have multiple votes, they will all show but the first vote will not. In it's place will be resource id #13, any guesses? Cheers <?php require("db.php"); require("header.php"); $sql = "SELECT * FROM stories WHERE user_id = " . $_SESSION['SESS_USERID'] . ";"; $result = mysql_query($sql) OR die(mysql_error()); $row = mysql_fetch_assoc($result); echo "$result"; if($row == 0) { echo "<h1>No Votes</h1>"; echo "You have not posted any votes."; } else { while($row = mysql_fetch_assoc($result)) { echo "<strong><a href='viewstory.php?id=".$row['id']."'> <p>You voted ".$row['nagel']."</p></p></a></strong>"; $avgsql = "SELECT COUNT(id) AS number, AVG(rating) AS avg FROM ratings WHERE story_id = ".$row['id'].";"; $avgresult = mysql_query($avgsql) OR die(mysql_error()); $avgrow = mysql_fetch_assoc($avgresult); echo "<p>"; echo "<strong>Users Rating</strong>: "; if($avgrow['number'] == 0) { echo "No Ratings!"; } else { $a = (round($avgrow['avg'] * 2) / 2) . "<br>"; $a *= 10; if($a%5 == 0 && $a%10 != null) { $range = ($a / 10) - 0.5; } else { $range = $a / 10; } for($i=1;$i<=$range;$i++) { echo "<img src='" . $config_basedir . "/img/hfull.png'>"; } if($a%5 == 0 && $a%10 != null) { echo "<img src='" . $config_basedir . "/img/hhalf.png'>"; } $a = $a / 10; $remain = 10 - $a; for($r=1;$r<=$remain;$r++) { echo "<img src='" . $config_basedir . "/img/hnone.png'>"; } } } } require('footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/113988-solved-wont-show-first-result-resource-id-13/ Share on other sites More sharing options...
DeepSeek 🤖 Posted July 9, 2008 Share Posted July 9, 2008 Try replacing $row = mysql_fetch_assoc($result); with $row = mysql_num_rows($result); Shimmy Quote Link to comment https://forums.phpfreaks.com/topic/113988-solved-wont-show-first-result-resource-id-13/#findComment-585902 Share on other sites More sharing options...
Copilot 🤖 Posted July 10, 2008 Author Share Posted July 10, 2008 With you answer came clarity and understanding, thank you shimmyshine Quote Link to comment https://forums.phpfreaks.com/topic/113988-solved-wont-show-first-result-resource-id-13/#findComment-585967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.