gpt4 book ai didi

php - 函数不显示表格

转载 作者:行者123 更新时间:2023-11-28 06:27:57 25 4
gpt4 key购买 nike

这给了我错误和 idk 为什么,表确实存在但仍然不工作,我做错了什么?

内容确实显示了,但仍然报错,没有显示应有的内容

function content_temp()
{
if(isset($_GET['action']))
{
if($_GET['action'] == 'banlist')
{
echo " <div class='positiontable'>
<table class='MYTABLE'>
<tr CLASS='MYTABLE'>
<th CLASS='MYTABLE' height=40 width=80>User</th>
<th CLASS='MYTABLE' height=40 width=80>Time</th>
<th CLASS='MYTABLE' height=40 width=180>Reason</th>
<th CLASS='MYTABLE' height=40 width=80>Admin</th>
</tr>
</table>
</div> ";

$query ="SELECT * FROM `Banovi` LIMIT 5";
$row = mysqli_fetch_array($query);
if($row)
$name = $row['Ime'];
$time = $row['Vreme'];
$reason = $row['Razlog'];
$admin = $row['Admin'];
echo " <tr CLASS='MYTABLE'>
<td CLASS='MYTABLE' height=40 width=80>$name</td>
<td CLASS='MYTABLE' height=40 width=80>$time</td>
<td CLASS='MYTABLE' height=40 width=180>$reason</td>
<td CLASS='MYTABLE' height=40 width=80>$admin</td>
</tr>";
}
}
}

最佳答案

更新 2

你可能需要做一些改变:

function content_temp( $con ){
if(isset($_GET['action'])){
if($_GET['action'] == 'banlist'){
echo " <div class='positiontable'>
<table class='MYTABLE'>
<thead>
<tr CLASS='MYTABLE'>
<th CLASS='MYTABLE' height=40 width=80>User</th>
<th CLASS='MYTABLE' height=40 width=80>Time</th>
<th CLASS='MYTABLE' height=40 width=180>Reason</th>
<th CLASS='MYTABLE' height=40 width=80>Admin</th>
</tr>
</thead>
<tbody>";
$query ="SELECT * FROM `Banovi` LIMIT 5";
$result = mysqli_query($con,$query);
while( $row = mysqli_fetch_array($result,MYSQLI_ASSOC) ){

$name = $row['Ime'];
$time = $row['Vreme'];
$reason = $row['Razlog'];
$admin = $row['Admin'];
echo "
<tr CLASS='MYTABLE'>
<td CLASS='MYTABLE' height=40 width=80>$name</td>
<td CLASS='MYTABLE' height=40 width=80>$time</td>
<td CLASS='MYTABLE' height=40 width=180>$reason</td>
<td CLASS='MYTABLE' height=40 width=80>$admin</td>
</tr>";
}?>
</tbody>
</table><?php
}
}
}

更新 1

content_temp( $con ) 中,应该创建 $con 并在函数调用时传递:

$con = mysqli_connect("localhost","my_user","my_password","my_database");
content_temp( $con );

关于php - 函数不显示表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35158710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com