Hey guy's, have been stuck at this hurdle for a little whole now and I can't seem to find the right solution and would very much appreciate anyones help on this.
Ok, so I have a table of votes and each time a user votes, they're added to this table. Now, I have a 'pool' table which will display certain items. What I'm trying to do is display the 'pool' items, but if this specific user has already voted on this particular item, then I want it to skip the item in the 'pool' and go to the next item, until the argument of has that user voted is false.
The current code I'm pasting will obviously not work, it isn't even in the right position, but I've separated it so that you can hopefully understand what I'm trying to do in order to help.
Below is the code I use to check if a user has already voted on a particular photo:
<?php
$result=mysql_query("SELECT * FROM votes WHERE vVoter='$_SESSION[userID]' AND vPhoto='$_SESSION[currentphoto]'");
$rowCheck = mysql_num_rows($result);
$alreadyv = 0;
if($rowCheck > 0){
$alreadyv = 1;
//user has already voted on this photo, need to use this info to be able to skip it in the 'pool'
} else {
//do nothing
}
?>
totalVoted is basically how many times a user has voted, so that people who vote more, get more votes:
<?php
$result=mysql_query("SELECT * FROM pool ORDER BY totalVoted DESC LIMIT 1");
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
$photoid = $row['photoInPool'];
$result2=mysql_query("SELECT * FROM photos WHERE pID='$photoid'");
$rowCheck2 = mysql_num_rows($result2);
if($rowCheck2 > 0){
while($row2 = mysql_fetch_array($result2)){
if($alreadyv == 1) {
//I NEED THIS TO SHOW THE NEXT PHOTO IN THE ARRAY, HOWEVER, IF THEY HAVE ALREADY VOTED ON THE NEXT PHOTO, IT WILL STILL DISPLAY IT, THIS IS MY PROBLEM I NEED HELP WITH PLEASE
} elseif ($alreadyv != 1) {
$fname = $row2['pFileName'];
}
}
}
$_SESSION[currentphoto] = $row['photoInPool'];
echo "<center><img src='user_images/$fname'></center>";
}
}
?>
I hope I've explained this well enough and hope somebody can help. Many thanks in advance