如何动态创建表? [英] How to create a table dynamically?

查看:97
本文介绍了如何动态创建表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试动态创建表格。它有效,但我有一个错误:

Hi

I am trying to create a table dynamically. It works but I have an error:

Notice: Undefined index: in C:\xampp\htdocs\asset-management\reports\querys\by-status.php on line 20



然后这是我写的代码:


Then here is the code I have written:

$query = "SELECT ".$columns." Item FROM tblitem WHERE Status=".$_POST['status'];
$result = mysql_query($query);

$tblCol = explode(",", $columns);

echo "<table>";

echo "<th>Item</th>";
foreach ($tblCol as $ColName){
	echo "<th>".$ColName."</th>";
}
while($row = mysql_fetch_array($result)){
	echo "<tr>";
	echo "<td>". $row['Item'] ."</td>";
	foreach ($tblCol as $columnName){
		echo "<td>". $row[$columnName] ."</td>";
	}
	echo "</tr>";
}

echo "</table>";



有人能帮助我吗?它工作正常,但错误不会消失。


Can some one help me? It works fine but the error does not disappear.

推荐答案

query = SELECT


columns。 Item FROM tblitem WHERE Status =
columns." Item FROM tblitem WHERE Status=".


_POST [' 状态];
_POST['status'];


这篇关于如何动态创建表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆