Hi, well it's fairly easy, assuming that you use MySQL, this would be done using SQL queries according to the number of tables that needs to be updated, in this particular example we're updating two tables so two queries are executed the queries should be wrapped in a single function so that they're executed as a block.
TABLE "nutrition"
CREATE TABLE nutrition
(
n_id INT NOT NULL AUTO_INCREMENT,
nutrition VARCHAR(30),
PRIMARY KEY(n_id) /* Set the primary key */
)
TABLE "category"
CREATE TABLE nutrition
(
n_id INT NOT NULL AUTO_INCREMENT,
category VARCHAR(30),
PRIMARY KEY(n_id) /* Set the primary key */
)
Now the PHP function that inserts records, I also assume that the MySQL Connection has been made, to make it clearer I've omitted the MySQL connection code.
<?php
function addFood($nutrition_val,$category_val)
{
$q_nutrition="INSERT INTO nutrition (nutrition) VALUES ($nutrition_val)";
$q_category="INSERT INTO category (category) VALUES ($category_val)";
mysql_query($q_nutrition); /* For table Nutrition */
mysql_query($q_category); /* For table category*/
}
?>
Hope it helps.
Regards, Triztian