Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [pomoc]Sonda
d12
post
Post #1





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 25.08.2003
Skąd: Bielsko-Biała

Ostrzeżenie: (0%)
-----


Witam. Ściągłem sobie skrypt jaco. Sonda 1.0, skonfigurowałem i wszystko ok. Głosuje i wywala taki błąd:
Warning: Cannot modify header information - headers already sent by (output started at c:usrkrasnalwwwtpoll.php:8) in c:usrkrasnalwwwtpollinc.php on line 95
A oto plik inc.php
[php:1:32fe30dd4e]
<?

# === === === === === === === ===

# autor: Paweł Jaczewski #
# email: jaco@g3.pl #
# strona: http://phparea.xu.pl #

# === === === === === === === ===


function poll_form() {

global $a_tbl, $b_tbl;


$query = "SELECT * FROM $a_tbl ORDER BY id DESC";
$result = mysql_query($query);

$r = mysql_fetch_array($result);

$id = $r['id'];
$votes = $r['votes'];
$title = $r['title'];


// =======================================
// zmiana wygladu formularza
// =======================================

echo '<form method="post" name="vote" action="poll.php">';
echo '<table border="0" align="center" width="100%">';
echo '<tr>
<td colspan="2"><p style="{font-family:Verdana;
font-size: 11px;
text-align: center;
text-valign:
top;font-weight: bold;
color:black">
'.$title.'<br></td>
</tr>';

$qu_ = "SELECT * FROM $b_tbl WHERE vid='$id' ORDER BY id";
$re_ = mysql_query($qu_);

while($r_ = mysql_fetch_array($re_)) {

$value = $r_['value'];
$title = $r_['title'];

if($title<>'')

echo '<tr>
<td valign="top"><input type="radio" name="voteVALUE" value="'.$value.'"></td>
<td class="menu" width="90%"><p style="{font-family:Verdana;
font-size: 11px;
text-align: left;
text-valign:
top;font-weight: normal;
color:black"> '.$title.'</td>
</tr>';


}

echo '
<tr>
<td colspan="2" class="menu">
<center><input type="submit" name="ok" value="Głosuj" style="background-color: #C9D7DA; font-family: Verdana; font-size: 11px; border-bottom: black 1px solid; border-top : black 1px solid; border-left: black 1px solid; border-right: black 1px solid;">

<p style="{font-family:Verdana;
font-size: 10px;
text-align: center;
text-valign:top;
font-weight: bold;
color:black">

[<a href="poll.php">wyniki</a> | <a href="poll.php?cmd=old">ankiety</a>]</td>
</tr>
</table>
<input type="hidden" name="cmd" value="count">
<input type="hidden" name="pollID" value="'.$id.'">
</form>';

}




function count_poll($id, $val) {

global $a_tbl, $b_tbl, $poll_cookie, $poll_err;

if($poll_cookie<>10) {
setcookie("poll_cookie", "10", time()+3700);
}

if($poll_cookie<>10) {

// ===========================================

$query = "SELECT * FROM $a_tbl WHERE id='$id'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);


$votes = $r['votes'];
$votes++;

$query = "UPDATE $a_tbl SET votes='$votes' WHERE id='$id'";
$result = mysql_query($query);

// ============================================

$query = "SELECT * FROM $b_tbl WHERE vid='$id' AND value='$val'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);

$count = $r['count'];
$count++;


$query = "UPDATE $b_tbl SET count='$count' WHERE vid='$id' AND value='$val'";
$result = mysql_query($query);

$poll_err = ' - Dzięki za oddanie głosu!</b>';

} else {

$poll_err = ' -
<p style="{font-family:Verdana;
font-size: 11px;
text-align: left;
text-valign:
top;font-weight: normal;
color:black">
<b>Nie możesz 2 razy głosować!</b></p>';


}

}


function poll_result($id='no') {

global $a_tbl, $b_tbl, $theme;

if($id<>'no') {

$query = "SELECT * FROM $a_tbl WHERE id='$id'";

} else {

$query = "SELECT * FROM $a_tbl ORDER BY id DESC LIMIT 1";

}

$result = mysql_query($query);
$r = mysql_fetch_array($result);

$id = $r['id'];
$votes = $r['votes'];
$title = $r['title'];


echo '<table width="300" border="0" valign="top" align="center">
<tr>
<td class="menu" colspan="2" ><center>
<b>
'.$title.'</b><br><br></td>
</tr>';

$query = "SELECT * FROM $b_tbl WHERE vid='$id' ORDER BY value";
$result = mysql_query($query);

while($r = mysql_fetch_array($result)) {

$title = $r['title'];
$count = $r['count'];

if($title<>'') {

if($votes<>0) {
$a = $count / $votes;
$a = $a * 100;
$a = round($a);
$b = $a * 2;
} else {
$a = 0;
$b = 0;
}

echo '<tr>

<td class="menu" width="30%">
'.$title.'</td>
<td class="menu" ><img src="poll/poll.gif" height="10" width="'.$b.'"> '.$a.'% ('.$count.')</td>
</tr>';


}

}

echo '<table width="90%" border="0" align="center">
<tr>
<td class="menu" colspan="2" ><br><br><center>ł&plusmn;cznie głosów oddano: <b>'.$votes.'</b></td>
</tr>';
echo '</table>';

}


function old_poll() {

global $a_tbl, $b_tbl, $theme;


$query = "SELECT * FROM $a_tbl ORDER BY id DESC";
$result = mysql_query($query);
$num = mysql_num_rows($result);

$s = 0;

if($num>1) {

echo '<hr size="1" noshade><center><b>Stare sondy</b></center><hr size="1" noshade><br>';

}

while($r = mysql_fetch_array($result)) {

$pollID = $r['id'];

if($s<>0) {
poll_result($pollID);
echo '<hr size="1" noshade><br>';
}

$s++;
}








}


?>[/php:1:32fe30dd4e]


--------------------
Pozdro D12
GG: 5455157; Email: redakcja@motoweb.pl
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 14:13