Ok, here is new code, and page is : www.squadinferno.com/jokes/pjokes.php
<?
require "jokecode.php";
$link = mysql_connect( "localhost", $user, $pass );
mysql_select_db( $db );
function showrate($joke_id) {
$get_count = mysql_query("SELECT joke_rating, joke_votes FROM joke_rate WHERE joke_id=$joke_id");
echo mysql_num_rows($get_count );
while(list($joke_rating, $joke_votes)=mysql_fetch_array($get_count)){
if ($joke_rating <> 0) {
$rating = ($joke_rating / $joke_votes);
} else {
$rating = $joke_rating;
}
if((($rating >= 0)or($rating == 0)) && ($rating <= 0.50)){
echo "<img src=../images/0o5.gif width=70 height=18>";
}
if((($rating >= 0.50)or($rating == 0.50)) && ($rating <= .99)){
echo "<img src=../images/05o5.gif width=70 height=18>";
}
if((($rating >= 1.00)or($rating == 1.50)) && ($rating <= 1.49)){
echo "<img src=../images/1o5.gif width=70 height=18>";
}
if((($rating >= 1.50)or($rating == 1.50)) && ($rating <= 1.99)){
echo "<img src=../images/15o5.gif width=70 height=18>";
}
if((($rating >= 2.00)or($rating == 2.00)) && ($rating <= 2.49)){
echo "<img src=../images/2o5.gif width=70 height=18>";
}
if((($rating >= 2.50)or($rating == 2.50)) && ($rating <= 2.99)){
echo "<img src=../images/25o5.gif width=70 height=18>";
}
if((($rating >= 3.00)or($rating == 3.00)) && ($rating <= 3.49)){
echo "<img src=../images/3o5.gif width=70 height=18>";
}
if((($rating >= 3.50)or($rating == 3.50)) && ($rating <= 3.99)){
echo "<img src=../images/35o5.gif width=70 height=18>";
}
if((($rating >= 4.00)or($rating == 4.00)) && ($rating <= 4.49)){
echo "<img src=../images/4o5.gif width=70 height=18>";
}
if((($rating >= 4.50)or($rating == 4.50)) && ($rating <= 4.99)){
echo "<img src=../images/45o5.gif width=70 height=18>";
}
if($rating == 5.0){
echo "<img src=../images/5o5.gif width=70 height=18>";
}
}
}
function ratemenu($joke_id){
echo "<form name=rating method=post action=pjokes.php>
<select name=rating>
<option value=5.0 selected>5 - Can't Breathe</option>
<option value=4.0>4 - Rolling</option>
<option value=3.0>3 - Laughing</option>
<option value=2.0>2 - Smiling</option>
<option value=1.0>1 - Not Funny</option>
<option value=0.0>0 - Didn't Finish Reading</option>
<input type=hidden name=cmd value=do_rating>
<input type=hidden name=joke_id value=$joke_id>
<input type=submit value=Go!>
</select>
</form>";
}
function do_rating($joke_id){
$get_count = mysql_query("SELECT joke_rating, joke_votes FROM joke_rate WHERE joke_id='$joke_id'");
while(list($joke_rating, $joke_votes)=mysql_fetch_array ($get_count)){
$new_count = ($joke_votes + 1);
$new_rating = ($joke_rating + $rating);
echo "Joke Rating: ".$joke_rating."<br>";
echo "Rating: ".$rating."<br>";
echo "New Rating: ".$new_rating."<br>";
$sql = "UPDATE joke_rate SET joke_rating='$new_rating',joke_votes='$new_count' WHERE joke_id='$joke_id'";
echo $sql."<br>";
$update_rating = mysql_query($sql);
}
}
?>
That's the functions file, called from the php code which is here:
print "<tr bgcolor=#323232>\n";
print "<td width=61><p class=dl align=right><a href=get.php?J1 style=text-decoration:none>1</a></p></td>\n";
print "<td width=62><p align=right><font color=#00ff00>$J1Round</font></p></td>\n";
print "<td width=150><p class=bodywhite align=center>\n";
print showrate(1);
print "</p></td>\n";
print "<td width=247><p class=bodywhite align=center>\n";
print ratemenu(1);
print "</p></td></tr>\n";
as you can see, I pass the $joke_id from the function call ratemenu(1) command, thus calling joke 1 and showrate(1), but the showrate works correctly, for joke 2 I entered 2 values manually into the database, 6 rating with 2 votes, just to make sure it calculated the rating correctly. Look on the page, and joke 2 is rated 2.5 stars, so that function call works. It's just the updating to the table that doesn't.
No Errors show.