Webmastersite.net
Register Log In

Custom Voting Help Needed
Need help with using 5 voting fields

Comments on Custom Voting Help Needed

timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted Apr 28, 2005 - 4:44 PM:

First off, the script is great! I love it. However, the only trouble I'm having is geting the voting fields to work. I added the new fields to the "image field" they were "clarityrating" "uniquerating" "complexrating" "skillrating" and "overallrating" But when I try to use any variables or try to vote it either says it's invaild or that I've already voted... Did I miss something?
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted Apr 30, 2005 - 10:55 AM:

This is my html to pass the votes to "vote.php?action=vote?id="

Is there anything wrong?

<table border="0" cellspacing="0" cellpadding="1">
<form action="vote.php?action=vote&id={IMAGEID}" method="post">

<tr>
<td> </td>
<td> 1 </td>
<td bgcolor="#DDDDDD"> 2 </td>
<td> 3 </td>
<td bgcolor="#DDDDDD"> 4 </td>
<td> 5 </td>
</tr>

<tr bgcolor="#CCCCCC">
<td align="right"> Clarity:</td>
<td><input type="radio" name="clarityrating" value="1" /></td>
<td><input type="radio" name="clarityrating" value="2" /></td>
<td><input type="radio" name="clarityrating" value="3" /></td>
<td><input type="radio" name="clarityrating" value="4" /></td>
<td><input type="radio" name="clarityrating" value="5" /></td>
</tr>

<tr>
<td align="right"> Uniqueness:</td>
<td><input type="radio" name="uniquerating" value="1" /></td>
<td bgcolor="#DDDDDD"><input type="radio" name="uniquerating" value="2" /></td>
<td><input type="radio" name="uniquerating" value="3" /></td>
<td bgcolor="#DDDDDD"><input type="radio" name="uniquerating" value="4" /></td>
<td><input type="radio" name="uniquerating" value="5" /></td>
</tr>

<tr bgcolor="#CCCCCC">
<td align="right"> Complexity:</td>
<td><input type="radio" name="complexrating" value="1" /></td>
<td><input type="radio" name="complexrating" value="2" /></td>
<td><input type="radio" name="complexrating" value="3" /></td>
<td><input type="radio" name="complexrating" value="4" /></td>
<td><input type="radio" name="complexrating" value="5" /></td>
</tr>

<tr>
<td align="right"> Skill:</td>
<td><input type="radio" name="skillrating" value="1" /></td>
<td bgcolor="#DDDDDD"><input type="radio" name="skillrating" value="2" /></td>
<td><input type="radio" name="skillrating" value="3" /></td>
<td bgcolor="#DDDDDD"><input type="radio" name="skillrating" value="4" /></td>
<td><input type="radio" name="skillrating" value="5" /></td>
</tr>

<tr bgcolor="#CCCCCC">
<td align="right"> Overall:</td>
<td><input type="radio" name="overallrating" value="1" /></td>
<td><input type="radio" name="overallrating" value="2" /></td>
<td><input type="radio" name="overallrating" value="3" /></td>
<td><input type="radio" name="overallrating" value="4" /></td>
<td><input type="radio" name="overallrating" value="5" /></td>
</tr>

<td colspan="6" align="right" height="30">
<input type="submit" name="Submit" class="button" value="Rate Image"></td>
</tr>

</form>
</table>
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted Apr 30, 2005 - 1:21 PM:

Ok Sorry, nevermind about the invalid stuff... This is the problem...

The only vote that goes through is "overall" because I changed name="overallrating" to "votevalue" but the custom fields aren't working. I have added the new fields correctly, i believe, they are "clarityrating" "uniquerating" "complexrating" "skillrating". I used the "Add Fields" page and added using "Add [image field] named [XXXrating]" type [input box]. No other options were used...
Did I do it right?

The following shows a 0 rating for all rating fields except for the first "votevalue" rating.

<IF {SWITCH_RATINGS}><div class="details">

<span class="labels">Overall Rating:</span>
{IMAGESTARS} {IMAGERATING}/{MAXVOTE} <br>

<span class="labels">Uniqueness:</span>
{IMAGEUNIQUERATINGSTARS} {IMAGEUNIQUERATINGRATING}/{MAXVOTE} <br>

<span class="labels">Skill:</span>
{IMAGESKILLRATINGSTARS} {IMAGESKILLRATINGRATING}/{MAXVOTE} <br>

<span class="labels">Complexity:</span>
{IMAGECOMPLEXRATINGSTARS} {IMAGECOMPLEXRATINGRATING}/{MAXVOTE} <br>

<span class="labels">Clarity:</span>
{IMAGECLARITYRATINGSTARS} {IMAGECLARITYRATINGRATING}/{MAXVOTE} <br>

based on {IMAGEVOTES} votes</div></IF>

It can be found at...
http://www.ratemyphotography.net/test/link.php?id=3

Please help ...
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted May 01, 2005 - 6:45 AM:

timismyname wrote:
<input type="radio" name="clarityrating" value="1" />


Based on a glance at the code, to send the vote you need to send clarityratingvotevalue. <input type="radio" name="clarityratingvotevalue" value="1" />

Fixed the manual entry.
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted May 01, 2005 - 4:16 PM:

I have changed all of the name="XXXrating" to "XXXratingvotevalue" and it says the vote has been recorded, but still displays the other ones as 0... I'm still using the same code as above, except the adding of "votevalue" to all the names, and it's still not working.

Is there something I missed?
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted May 02, 2005 - 5:01 PM:

It's still not working... are the fields correct??

[image field] named [XXXrating]" type [input box]. No other options were used...

Please help...
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted May 02, 2005 - 5:36 PM:

I went to phpadmin and into the link table...

It appears the custom fields are counting the number of votes and not the vote itself. Also... the "XXXratingvotevalue" didn't increase the number any. So I changed it back to "XXXrating" and when I voted the number increased by 1.

????? I don't know how to fix it, but I believe that is the problem.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted May 03, 2005 - 1:14 PM:

Annoyingly, it looks like I should pay attention to the manual instead of editing it. The tempalate code you had originally was correct, there's just a bug in vote.php. Change


if ($votevalue > $settings->maxvote) die("Illegal vote attempted"); // prevent cheating

if ($votevalue < $settings->minvote) die("Illegal vote attempted");

// find out existing vote data for this link

$thislink->voterips .= ' '. $_SERVER['REMOTE_ADDR'] .' ';

if ($thismember->id > 0) $thislink->voterids .= ' '. $thismember->id .' ';

if ($votevalue > 0)

{

$thislink->sumofvotes += $votevalue;

$thislink->votes = $thislink->votes + 1; // incriment the vote counter

$rating = ($thislink->sumofvotes)/($thislink->votes);

$thislink->rating = $rating;

// update the link in the database with the new vote info

$result = $thislink->update('votes,sumofvotes,rating,voterips,voterids');

$db->insert('ratingstable', 'memberid,votevalue,time,ip,custom,linkid', "'". $thismember->id ."','". $votevalue ."','". time() ."','". $_SERVER['REMOTE_ADDR'] ."','','". $thislink->id ."'");

}
// handle custom rating fields


to
	if ($votevalue)
{ // if custom ones only, skip this

if ($votevalue > $settings->maxvote) die("Illegal vote attempted"); // prevent cheating

if ($votevalue < $settings->minvote) die("Illegal vote attempted");

// find out existing vote data for this link

$thislink->voterips .= ' '. $_SERVER['REMOTE_ADDR'] .' ';

if ($thismember->id > 0) $thislink->voterids .= ' '. $thismember->id .' ';

if ($votevalue > 0)

{

$thislink->sumofvotes += $votevalue;

$thislink->votes = $thislink->votes + 1; // incriment the vote counter

$rating = ($thislink->sumofvotes)/($thislink->votes);

$thislink->rating = $rating;

// update the link in the database with the new vote info

$result = $thislink->update('votes,sumofvotes,rating,voterips,voterids');

$db->insert('ratingstable', 'memberid,votevalue,time,ip,custom,linkid', "'". $thismember->id ."','". $votevalue ."','". time() ."','". $_SERVER['REMOTE_ADDR'] ."','','". $thislink->id ."'");

}
}

// handle custom rating fields
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
Posted May 04, 2005 - 4:15 PM:

:-( That didn't fix it.
The only one working is still only "votevalue".
The other ones do the following:
Under the Link table under "clartityrating" "uniquerating" etc. the values still only increase by 1 each time I vote, I'm testing with ratings all at 5, and then I tried all at 4, same result.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#10 - Quote - Permalink
Posted May 05, 2005 - 5:53 PM:

I gave a clarityrating of 4 and it showed the clarityrating being 4. I have this in my template:


<p>Current clarityrating is {IMAGECLARITYRATINGRATING}. Vote!</p>

<form action="vote.php?action=vote&id={IMAGEID}" method="post">
<table {STANDARDTABLE}>
<tr>
<td class="labelscolumn"><span class="labels">Rate this image clarity:</span></td>
<td class="optionscolumn">
<select name="clarityrating">
<option value="5">5 - Perfect</option>
<option value="4">4 - Good</option>
<option value="3">3 - Average</option>
<option value="2">2 - Mediocre</option>
<option value="1">1 - Bad</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Submit Rating" class="button"></td>
</tr>
</table>
</form>
timismyname
Beginner

Usergroup: Member
Joined: Apr 26, 2005

Total Topics: 1
Total Comments: 8
#11 - Quote - Permalink
Posted May 07, 2005 - 1:18 PM:

I have changed nothing else and the {IMAGECLARITYRATINGRATING} still comes out as 0.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#12 - Quote - Permalink
Posted May 08, 2005 - 2:02 AM:

Well, get the vote.php from the revision of 2.15 just uploaded. That's what I'm using, and it works fine.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.