Jump to content
Old threads will finally start getting archived ×

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

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.