Example: I have a product with 10 units registered in a database, a customer buys 1 unit, this unit gives low and quantity of the product goes to 9 units.
How to express this in PHP?
Example: I have a product with 10 units registered in a database, a customer buys 1 unit, this unit gives low and quantity of the product goes to 9 units.
How to express this in PHP?
Any system is based on management of various database information such as MySQL, PostgreSQL, MARIADB ... CRUD is independent of the programming language used.
CRUD are four basic operations used in relational databases to manage all information to be stored, queried, and deleted.
From the moment you understand and understand the CRUD process you can interact with the SGDB / strong> of your choice. One of the most used in the market is MySQL mainly in the case of PHP programming language.
Since you store all of your information inside variables and send and receive the required information via $_GET[]
, $_POST[]
and $_REQUEST[]
, you can send and receive them from your MySQL. Most of the time, this information travels through the forms or commands mentioned above.
Example sending and receiving information:
$produto = $_POST['nome_produto'];
$preco = $_POST['preco'];
$quantidade = $_POST['quantidade'];
Sample connection to the database
mysql_connect('host', 'user', 'pass');
mysql_select_db('db');
Use MySQL or PDO, MySQL is being discontinued.
Once you are connected to the database, use Xampp or WampServer to work on local machine (localhost, on your pc) >, you can start using CRUD ...
CRUD
mysql_query("INSERT INTO (colunas) VALUES (valores) ...);
mysql_query("SELECT * FROM vendas WHERE id_compra = '10');
mysql_query("UPDATE vendas SET pago = 'pago' WHERE id_compra = '10';
mysql_query("DELETE FROM vendas WHERE id_compra = '10'");
There is vital information there for all the people who need to start treading stones in the programming area.