我需要你的帮助,我有这张表格:
以及何时提交插入MySQL DB,此表。
我希望在某些表格中显示信息与第一张图像Fiddle完全一样,我的意思是填充了DB的信息,但只有我能得到这个:
我不知道该怎么做,这是我使用的代码,显然不是我想要的。
<?php
$sqlStr = "SELECT prov_name, unitval, totval
FROM provprices where CA_id = ".$CA_id;
$sqlStrAux = "SELECT count(*) as total FROM provprices";
$aux = Mysql_Fetch_Assoc(mysql_query($sqlStrAux));
$query = mysql_query($sqlStr);
if($aux['total']>0){
echo "</br></br>";
echo "<div class='datagrid'>";
echo "\t<table border='1'>\n";
echo "<thead>";
echo "<tr>
<th>unitval</th>
<th>totval</th>
</tr>\n";
echo "</thead>";
echo "<tbody>";
while($row = mysql_fetch_assoc($query)){
echo "\t\t<tr>
<td>".htmlentities($row['unitval'])."</td>
<td>".$row['totval']."</td>
</tr>\n";
}
echo "</tbody>";
echo "\t</table>\n";
}
echo "</div>";
?>
POST架构表:
CREATE TABLE IF NOT EXISTS `provprices` (
`CA_id` int(11) NOT NULL,
`prov_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`unitval` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`totval` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
KEY `CA_id` (`CA_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `provprices`
ADD CONSTRAINT `provprices_ibfk_1` FOREIGN KEY (`CA_id`) REFERENCES `compras_activos` (`CA_id`);