<?php
foreach (iscupaj_viceve() as $id => $glasanje){
$result = mysql_query("SELECT * FROM vicevi WHERE id = $id");
while ($row = mysql_fetch_array($query)) {
echo "<h2><center>".$row['Title']."</h2>";
echo "<div id='linkovi1'>" .nl2br($row["VicText"]). "<br></div>";
}
?>
<p>
<a href="?glasanje=gore&id=<?php echo $id; ?>"><img src="../images/plus_sign.png" width="29" height="29"></a>
<a href="?glasanje=dolje&id=<?php echo $id; ?>"><img src="../images/minus_sign.png" width="29" height="29"></a>
Ukupno glasova : [
<?php
include 'core/db/connect.php';
// Check connection
$result = mysql_query("SELECT glasanje FROM vicevi WHERE id = $id");
while($row = mysql_fetch_array($result))
{
echo nl2br($row['glasanje']);
}
?>]
</p>
<?php
}
?>
这是我的功能
function iscupaj_viceve(){
$sql = "SELECT id, VicText, glasanje FROM vicevi ORDER BY id DESC LIMIT 0, 10";
$rezultati = mysql_query($sql);
$glasanje = array();
while (($row = mysql_fetch_assoc($rezultati)) !== false){
$rezultati[$row['id']] = $row['VicText'];
}
return $rezultati;
}
浏览器打印此错误消息:
警告:在第 111 行的 C:\xampp\htdocs\glasanje\index.php 中为 foreach() 提供的参数无效
但我似乎找不到解决这个问题的方法:S 帮助?