I need your help, I have this form table:
and when is submitted inserts in a MySQL DB, this table.
And i want to show that info in some table exactly like the first image like Fiddle, I mean filled with the info from DB, but only I can get this:
I don't know how to do that, this is the code that I use, obviously don't works like I want.
<?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'>
";
echo "<thead>";
echo "<tr>
<th>unitval</th>
<th>totval</th>
</tr>
";
echo "</thead>";
echo "<tbody>";
while($row = mysql_fetch_assoc($query)){
echo "\t\t<tr>
<td>".htmlentities($row['unitval'])."</td>
<td>".$row['totval']."</td>
</tr>
";
}
echo "</tbody>";
echo "\t</table>
";
}
echo "</div>";
?>
POST Schema table:
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`);