Make a function to load product list, filter products by companies
In this practice, I will introduce one method programming access database to load products in database and show up as a menu. About display data, we have to follow the design of html project. Otherwise, I am also introduce a method filter products by companies. A small note here, filter data usually get available from url so It is very easy mistake SQL-Injection. To solve that problem, usually refer security category in this website.
1. Create table to stores information of products
To stores information of products you have to create table in MySQL and put its name is sanpham. Including: id: primary key, auto increment; tensp: stores name of products; gia: price of products; mota: describe for products; idcty: stores id for congty table.
I want you know it is information very basic for one table. In real project, it need more like discount, suggest… You should research how to make a good database. Otherwise, for filter data usually get available from url so sometimes mistake SQL-Injection. To sole that one, refer security category in this website.
2. Design formatting for show up products
To have one formatting “simple” for show up small information of products, follow the designing below:
Result of this design:
Loadrightproduct were built base on two issues: access to database, design formatting show up data.
3. Make a function to load products from database
4. Video for more details
Introduce install software for programming in PHP
Layout basic website
embed menu into web page
PHP programming connect MySQL database