Jump to content

[SOLVED] Won't Show First Result - Resource id #13


GreenUser

Recommended Posts

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');

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.