Ik heb een poll op me site zonder errors. Alleen hij is niet zichtbaar. Weet iemand hoe dit kan terwijl hij wel zichtbaar hoort te zijn. Want hij connect gewoon. Dit is de poll code.
PHP
<h1>Poll</h1>
<div class="cwrap">
<?php
$connectie = @new MYSQLi($host,$gebruiker,$wachtwoord,$database);
return $connectie;
if(connectie()->connect_error);
{
header('Location: http://www.domeinnaam.nl');
die('Database error');
}
if(isset($_POST['vote']) && isset($_POST['questions'])){
$query = mysql_query("SELECT questions.pid FROM responses, questions WHERE responses.qid=questions.id AND responses.ip='".$CUR_IP."' AND pid=(SELECT pid FROM questions WHERE id='".$_POST['questions']."' LIMIT 1)");
if(mysql_num_rows($query) == 0){
$query = mysql_query("INSERT INTO responses (qid, ip) VALUES ('".$_POST['questions']."', '".$CUR_IP."')");
} else {
$error = 'Je hebt al gestemt';
}
} else if(!isset($_POST['questions']) && isset($_POST['vote'])){
$error = 'Selecteer een vraag';
}
$query = mysql_query("SELECT * FROM poll ORDER BY id DESC LIMIT 1");
$rows = mysql_num_rows($query);
if($rows > 0){
$poll = mysql_fetch_array($query);
$title = $poll['name'];
} else {
$title = 'Er is nog geen poll';
}
$query = mysql_query("SELECT COUNT(id) as hits FROM responses GROUP BY qid");
while($row = mysql_fetch_array($query)){
$me[] = $row['hits'];
}
if(!empty($me))
{
$max = max($me);
}
$query = mysql_query("SELECT questions.pid FROM responses, questions WHERE responses.qid=questions.id AND responses.ip='".$CUR_IP."' AND pid='".$poll['id']."'");
if(mysql_num_rows($query) > 0){
$total = mysql_query("SELECT questions.pid FROM responses, questions WHERE responses.qid=questions.id AND pid='".$poll['id']."'");
$total = mysql_num_rows($total);
?>
<table style="width:100%;">
<tr>
<td><strong><?php echo $title; ?></strong></td>
</tr>
<?php
$query = mysql_query("SELECT * FROM questions WHERE pid='".$poll['id']."' ORDER BY question");
$questions = mysql_num_rows($query);
if($questions > 0){
?>
<tr>
<td style="padding: 5px;">
<table style="width:100%;">
<?php
if(isset($error)){
?>
<tr>
<td colspan="2" style="padding: 0px 0px 10px 0px;"><?php echo $error; ?></td>
</tr>
<?php
}
?>
<?php
while($question = mysql_fetch_array($query)){
$responses = mysql_query("SELECT count(id) as total FROM responses WHERE qid='".$question['id']."'");
$responses = mysql_fetch_array($responses);
if($total > 0 && $responses['total'] > 0){
$percentage = round(($responses['total'] / $max) * 100);
} else {
$percentage = 0;
}
$percentage2 = 100 - $percentage;
?>
<tr>
<td ><?php echo $question['question']; ?></td>
<td style="height:10px; width:100%; padding: 0px 10px;">
<table style="width:100%;">
<tr style="height:10px;">
<td style="width:<?php echo $percentage; ?>%; <?php if($percentage > 0){?>background: url('/images/poll/bar.jpg') repeat-x;<?php } ?>"><img src="/images/poll/dot.gif" style="width:1px; height:19px;" /></td>
<td style="width:<?php echo $percentage2; ?>%;"></td>
</tr>
</table>
</td>
<td><?php echo $responses['total']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="3" style="padding: 10px 0px 0px 0px;">Aantal stemmen: <?php echo $total; ?></td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table>
<?php
} else {
?>
<table style="width:100%">
<tr>
<td><strong><?php echo $title; ?></strong></td>
</tr>
<?php
$query = mysql_query("SELECT * FROM questions WHERE pid='".$poll['id']."' ORDER BY question");
$questions = mysql_num_rows($query);
if($questions > 0){
?>
<tr>
<td style="padding: 5px;">
<form name="poll" method="post" action="/poll/">
<table>
<?php
if(isset($error)){
?>
<tr>
<td colspan="2" style="padding: 0px 0px 10px 0px;"><?php echo $error; ?></td>
</tr>
<?php
}
?>
<?php
while($question = mysql_fetch_array($query)){
?>
<tr>
<td style="padding: 0px 10px 0px 0px;"><input type="radio" name="questions" value="<?php echo $question['id']; ?>" /></td>
<td style="width:100%;"><?php echo $question['question']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2" style="text-align:right;"><button type="submit" name="vote">Stemmen</button></td>
</tr>
</table>
</form>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</div>
Toon Meer