I am working on building a Webstie for a restaurant and because clients will need to be able to order the items from the menu I've got to store everything on a MySQL database.
Now, everything is going to be organized visually in "cards"(you'll see what i mean in the image below) and each card is made up by an image and the title. Since I'm using PHP to deal with the SQL Queries and connection, the only thing I need is that once a card has been clicked, a new page gets presented with the same style, the same js scripts that I have, in other words, everything the same to the main page but with the correct number and type of cards.
You might have noticed that there are cards that create new pages with other cards inside and there are other cards, usually the last ones at the tree(image 3) that only create the menu. I've built everything and it works but all the data was stored inside JSON files and I had to copy the div for each card and create HTML pages for every category manually.
Now, I have already put everything inside the MySQL Database, I am referring to each item's data. So, what I need to do is simply create other html pages with different cards inside or create a menu(depending on the type of card). So, I understood that I need to create a tree, I thought about doing it in PHP in this way:
$tree = array("Drinks" => array(
"Alcholic" => array("Beers", "Vodka", "Wines"),
"Non-Alcholic" => array("Juices", "Something Else...")
),
"Food" => array(
//...
)
);
But, I don't have any idea about how to go from here. I tried my best to explain my objective in a clear and precise way. If, for any reason you need more details I will edit the post without any problems. This is a serious job and I will be very greatful for any amount of help I can get. Thanks in advance and have a great day!
You could use url parameter and do it all on one page, fetching data from db and creating cards dynamically based on the fetched result. For example:
if (isset($_GET['type') {
//suppose I clicked drinks
//then fetch drink types from db and and loop over them to create cards
//for example
<a href='index.php/?type=alcoholic'><img src='alcoholic.jpg'></a>
} else {
//show home page categories (drinks, food) if no parameter in url
//for example
<a href='index.php/?type=drinks'><img src='drinks.jpg'></a>
}
Alternatively, you could create separate pages for each subcategory, but that would be just duplicating the code.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL.
It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.