Fotokonkurence detajle

connect_errno > 0){
die(‘Unable to connect to database [‘ . $link->connect_error . ‘]’);
}

if (!$link->set_charset(“utf8”)) {
printf(“Error loading character set utf8: %s\n”, $link->error);
}
$imageID = $_GET[‘id’];
$user_ID = get_current_user_id();

$query1 = “SELECT * FROM contest_votes WHERE imageID=”.$imageID;

if(!$result = $link->query($query1)){
die(‘There was an error running the query [‘ . $link->error . ‘]’);
}
$numResults = $result->num_rows;

echo “

Dette billede har fået “.$numResults.” stemmer

“;

$query2 = “SELECT * FROM contest_votes WHERE userID LIKE “.$user_ID.” AND imageID != 0″;

if(!$result = $link->query($query2)){
die(‘There was an error running the query [‘ . $link->error . ‘]’);
}
$numResults = $result->num_rows;
$votesLeft = 2-$numResults;
$votedForThis = false;
if ($numResults > 0){

$counter = 0;
while ($votes = $result->fetch_assoc()) {
$userVotes[$counter] = $votes[‘imageID’];
$counter++;
}
if ($userVotes[0] == $imageID || $userVotes[1] == $imageID ){
$votedForThis = true;
}

}

echo ““;

if (!$votedForThis){
if ($votesLeft > 0){
echo “

Du har “.$votesLeft.” stemme(r) tilbage

“;
echo “

\n

“;
}
}else{
echo “

Du har stemt på dette billede

“;
}

?>