I have calculated the average price of products by type in a table and gotten the results into my screen. How do I store them into a table as well. Here is the code I have. it works other than to store into a table.
function mostrarDatos ($resultado) {
if ($resultado !=NULL) {
echo "- Promedio de Categoria ".'Producto_Prioridad'." es:".$resultado['total_average']."<br/>";
}
else {
echo "<br/>No hay más datos!!! <br/>";
}
}
$link = mysqli_connect("db", "user", "pass");
mysqli_select_db($link, "db");
$promedio = mysqli_query($link, "SELECT AVG( Producto_Precio ) as total_average FROM`Natan_Productos` GROUP BY Producto_Prioridad");
while ($fila = mysqli_fetch_array($promedio)){ // loops 4 times and displays on screen. How to store into table as well
mostrarDatos($fila);
}
mysqli_free_result($promedio);
mysqli_close($link);
for results I get:
- Promedio de Categoria Producto_Prioridad es:150.0000 //Loop 1
- Promedio de Categoria Producto_Prioridad es:38.3333 //Loop 2
- Promedio de Categoria Producto_Prioridad es:30.0000 //Loop 3
- Promedio de Categoria Producto_Prioridad es:31.6667 //Loop 4
Thanks for the help.