我想通过一个功能来做到这一点。我希望数据库中找到的每个项目都作为列表回显
例如。物品1
ITEM2
项目3
ITEM4
我知道我错过了一些东西,但这令我感到困惑。现在我只看到一个列表,然后 刷新另一项显示替换另一项。请帮助和谢谢
function get_list() {
$id = mysql_real_escape_string(@$_GET['id']);
$get_list = array();
$bar = mysql_query(" SELECT bar.* FROM bar WHERE bar.b_id = '$id' ORDER BY rand()");
while($kpl = mysql_fetch_assoc($bar)){
$get_list[] = array( 'videoid' => $kpl['videoid'],
'name' => $kpl['name'],
'description' => $kpl['description'],
'type' => $kpl['type'],
'bev' => $kpl['bev'],
);
}
foreach ($get_list as $get_list);
return $get_list;
}
?>
<?php
$gkp_list = gkp_list();
foreach ($gkp_list as $gkp_list);
if (empty($gkp_list)){ echo 'no video'; }
else {
echo '<p>$gkp_list['name']. '<br/></p>';}
?>
答案 0 :(得分:2)
那里有一些主要的语法问题。
function get_list() {
$id = mysql_real_escape_string(@$_GET['id']);
$get_list = array();
$bar = mysql_query(" SELECT bar.* FROM bar WHERE bar.b_id = '$id' ORDER BY rand()");
while($kpl = mysql_fetch_assoc($bar)){
$get_list[] = $kpl;
}
return $get_list;
}
$gkp_list = get_list();
if (empty($gkp_list)) {
echo 'no video';
} else {
foreach ($gkp_list as $gkp_item) {
echo '<p>' . $gkp_item['name']. '<br/></p>';
}
}
?>