Suppose there are 3 links to the same php file on the website of the online store, let it be: clothes for women, clothes for men, clothes for children. In the php file, a simple gallery pagination. How to make so that depending on the link, the corresponding result was issued? That is, by clicking on "clothes for women" in the gallery were pictures of the database with dresses, etc.
|
1 answer
For links, add, for example, GET parameters:
<a href="/shop.php?filter=1">для женщин</a> <a href="/shop.php?filter=2">для мужчин</a> <a href="/shop.php?filter=3">для детей</a> In shop.php, check the value in the link and correct the database request
<? if(isset($_GET['filter'])) { if($_GET['filter'] == 1) $add = " WHERE `section` = 'men'"; elseif($_GET['filter'] == 2) $add = " WHERE `section` = 'women'"; elseif($_GET['filter'] == 3) $add = " WHERE `section` = 'children'"; } $sql = "SELECT * FROM `clothes`".$add; ?> In the database, respectively, you need to store information about the type of clothing for each row.
|