<?php
require'fun.php';
$chestionar=$conn->query('SELECT`de`,`intrebare`,`varianta1`,`varianta2`,`varianta3`,`varianta4`,`varianta5`,`data`FROM`chestionar_intrebari`WHERE`id`="'.$pid.'"')->fetch_row();
$chestionar[8]=mb_substr($chestionar[1],0,15);
$chestionar[9]=$conn->query('SELECT`id`FROM`forum_topicuri`WHERE`tid`="'.$pid.'"')->fetch_row()[0];
if($chestionar[9]>0)
require'f_forumm.php';
require'f_conectare.php';
conectare('chestionar '.$chestionar[8],'chestionar/id/'.$pid.'-'.seo($chestionar[8]));
$head[1]='citeste și voteaza chestionarul cu intrebarea '.htmlspecialchars($chestionar[1]);
$titlu='Chestionar '.htmlspecialchars($chestionar[8]);
$back[1]='<a href="/chestionare">'.img('vot.gif',2).'Chestionare</a>';
require'f_sus.php';
echo$div[4].img('vot.gif',2).'Chestionar '.$chestionar[8].$div[5];
if($chestionar[1]!='')
{
require'f_profil.php';
require'f_filtru.php';
require'f_data.php';
echo$div[10].'Chestionar adăugat de '.profil($chestionar[0]).'<br /><small>Chestionar adaugat: '.data($chestionar[7]).'</small><br /><small>BBCode: <strong>[url=/chestionar/id/'.$pid.'-'.seo($chestionar[8]).']'.htmlspecialchars($chestionar[8]).'[/url]</strong></small><br />Intrebare: '.filtru($chestionar[1]).$div[0];
$voted=($conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`de`="'.$de.'"&&`pid`="'.$pid.'"')->fetch_row()[0]>0?true:false);
$nov=$conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`pid`="'.$pid.'"')->fetch_row()[0];
if($chestionar[2]!='')
{
$nov1=$conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`pid`="'.$pid.'"&&`valoare`="1"')->fetch_row()[0];
$rests=($nov>0?'Voturi: '.$nov1.' <strong>'.floor(($nov1/$nov)*100).'%</strong>':'Voturi: 0 <strong>0%</strong>');
echo$div[1].($voted?'1. '.htmlspecialchars($chestionar[2]).' '.$rests:'1. <a href="/voteaza-chestionar/id/'.$pid.'-'.seo($chestionar[8]).'/tip/1">'.htmlspecialchars($chestionar[2]).'</a> '.$rests).$div[0];
}
if($chestionar[3]!='')
{
$nov2=$conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`pid`="'.$pid.'"&&`valoare`="2"')->fetch_row()[0];
$rests=($nov>0?'Voturi: '.$nov2.' <strong>'.floor(($nov2/$nov)*100).'%</strong>':'Voturi: 0 <strong>0%</strong>');
echo$div[1].($voted?'2. '.htmlspecialchars($chestionar[3]).' '.$rests:'2. <a href="/voteaza-chestionar/id/'.$pid.'-'.seo($chestionar[8]).'/tip/2">'.htmlspecialchars($chestionar[3]).'</a> '.$rests).$div[0];
}
if($chestionar[4]!='')
{
$nov3=$conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`pid`="'.$pid.'"&&`valoare`="3"')->fetch_row()[0];
$rests=($nov>0?'Voturi: '.$nov3.' <strong>'.floor(($nov3/$nov)*100).'%</strong>':'Voturi: 0 <strong>0%</strong>');
echo$div[1].($voted?'3. '.htmlspecialchars($chestionar[4]).' '.$rests:'3. <a href="/voteaza-chestionar/id/'.$pid.'-'.seo($chestionar[8]).'/tip/3">'.htmlspecialchars($chestionar[4]).'</a> '.$rests).$div[0];
}
if($chestionar[5]!='')
{
$nov4=$conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`pid`="'.$pid.'"&&`valoare`="4"')->fetch_row()[0];
$rests=($nov>0?'Voturi: '.$nov4.' <strong>'.floor(($nov4/$nov)*100).'%</strong>':'Voturi: 0 <strong>0%</strong>');
echo$div[1].($voted?'4. '.htmlspecialchars($chestionar[5]).' '.$rests:'4. <a href="/voteaza-chestionar/id/'.$pid.'-'.seo($chestionar[8]).'/tip/4">'.htmlspecialchars($chestionar[5]).'</a> '.$rests).$div[0];
}
if($chestionar[6]!='')
{
$nov5=$conn->query('SELECT COUNT(*)FROM`chestionar_raspunsuri`WHERE`pid`="'.$pid.'"&&`valoare`="5"')->fetch_row()[0];
$rests=($nov>0?'Voturi: '.$nov5.' <strong>'.floor(($nov5/$nov)*100).'%</strong>':'Voturi: 0 <strong>0%</strong>');
echo$div[1].($voted?'5. '.htmlspecialchars($chestionar[6]).' '.$rests:'5. <a href="/voteaza-chestionar/id/'.$pid.'-'.seo($chestionar[8]).'/tip/5">'.htmlspecialchars($chestionar[6]).'</a> '.$rests).$div[0];
}
}
else
echo$div[7].'Acest chestionar nu a fost gasit!<br />Probabil a fost șters!'.$div[0];
require'f_jos.php';