Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Okay, so currently I'm creating a website from scratch for my small online shop and am stuck on where to even begin when it comes to my Products page. Currently, I have 1 page that displays all 50 of my products. I plan on expanding my products and do not want someone to be scrolling down the whole page. I would like to add multiple pages that you can click through and I believe I can accomplish this through Pagination. Now, this is the part where I get confused : say I only want 25 products to be displayed per page and I add a new item to the first page - how do items get 'bumped' to the page 2, 3 etc.? I would imagine there is some function to accomplish this, but the only way I can think of is doing this the brute force way of manually moving a product out of one page and onto another. Any suggestions??
Currently, my website is coded in all HTML / CSS and I currently just learned how to use PHP to mass edit certain areas of the website -- I am in the learning stages! Any suggestions would help. Thanks!
You need the help of a database to paginate your products in sets.
Basically, the database will have a "Products" table, each row in the table will represent a single product. You will use PHP to ask the database to retrieve the first/next N rows and then write out the appropriate HTML around each returned row to create a list of products.
There are lots of tutorials on the web to help you learn while you practice. Good luck!
There is no way to do that on static HTML web-site.
You need server-side script (e.g. PHP script) for splitting your product list by pages. By the way, you should store your data in DB and it should be done on the DB-side to not overhead your PHP side.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
so I am working on a small ecommerce site and I've been stuck on this section of my site for quite a while now and can't really wrap my head around it.
I have divided the site into 3 columns with bootstrap's grid system, in the main section I have my featured products, however, I'd like everything to be dynamic, when I click on a modal with "View details" for the product the only code that works is the dynamic one, I'd like to know how to make it so that it pulls the data directly from my database, unfortunately out of frustration I deleted the little work I had done on it and can't show stick it on here so that anyone can correct it for me.
Could anyone please help me out?
Thanks!
There are many ways you could go about doing this. Here is an approach you could use:
Get the id from data attribute of your product (make sure you load it into the html).
Send a $.get request with jquery for this id to the server.
Get the data needed from the db using this id.
Render the data server side
Return html
In the callback function of your get request put the HTML into your bootstrap modal body.
Show the modal to the user.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to learn, how to make a php content management system. I'm watching tutorials and reading documents about that but I couldn't understand something. For example there is 5 different page design.
Home Design
About Us Design
Products Design
Gallery Design
Contact Design
When I click new page button what should happen backside. Should it create a new php file or just insert a new line to the database. And for example when I want to create products pages at 3 different category. Should I need 3 products.php file or just one file for products design. And when I want to add a page should I design 5 different admin interface for each page? Actually I am not asking for code. I just want to learn the best way to do these things.
Thanks all :)
You should make a table in your database, call it "pages" and add columns:
id
title
content
published_date
status
and any other.
Then pass the page id via url (?p=123) and use query to show the relevant page via database.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I've read tons of questions who are in many ways the same as this one. But I just can't seem to understand how I am supposed to do this the proper way.
I've got one table with my pages.
And one table with portfolio items.
I want to be able to say to a portfolio item: You are linked to the welcome page now.
My approach:
In my pages table i've created a "items_linked" column. Inside this column the id's of the linked portfolio items get stored.
In the html of the 'edit page' I have a select with all my portfolio items, whichever I select gets stored inside the "items_linked".
I use the mysql UPDATE to get the information inside the database.
However this way I can't link a portfolio item to more than 1 page.
Because UPDATE removes the old information.
So I was guessing I needed a way to keep the old info, and add new info if the item is linked to a second page.
Can someone push me into the right direction?
Since we have no way of knowing what we are replacing I can only give you an idea of what to do:
UPDATE `table`
SET `myColumn` = CONCAT(`myColumn`, other_data)
WHERE some_condition_exists
This causes the information in myColumn to have additional data appended to it.
Here's the thing (caveat ahead): If you need one item to be linked to many items what I have described is not the way to go. You should have a table between the two you have already which will allow a one-to-many relationship between pages and portfolios. Please consider refactoring your database design.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The question is, if I have got 100 entries in my Database and want them all getting displayed on my page, how can I only show a selected Number like it's the case in webshops etc.
There you've got 37 products e.g. and after 10 products you have to select number 2 of the entry list.Its all split up in a few sites, but its still the same site.How can i achieve this.
You can achieve the pagination either by client side implementations or server side.
Client side (using Java Script/JQuery) and Server Side (using PHP) is preferable.
For client side, just follow this
link
For Server side
PHP Pagination
I notice that you put php, html and mysql as tags on your question so it's mean you don't have a clue on what you are doing. You should really study those things in separate a little more.
For the MySQL part you must study the limit directive.
The html part is not big deal also, you will have to make a pagination system. As said before Google is your friend.
On the server-side (php) you should look for the parameters/url on the page defined by the html part and make the proper query.
If I would enter in details of each of those steps I would have to write several paragraphs and still would be things missing. Well, at least I've given you directions, now you really should study more before attempting to do things like this.
Next time don't ask questions too vague/broad. Try to focus on specific issues rather than asking for the whole solution.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I just started learning PHP today and I have some conceptual questions regarding how I should use the language and accomplish specific tasks.
My question: Let's say I'm using PHP to build a CMS for a blog. On the home page I would like to have three articles show up that I have marked as "FEATURED" on the back-end in a field named is_featured.
Here is the solution I have come up with and I would like to know if this is possible with PHP, if it's practical, or if there is a better, more efficient way:
I would use a foreach loop to cycle through all $articles as $article and then check to see if that article has the value of FEATURED for the field is_featured.
In practice the articles would (probably, hopefully) be stored in a database in a table articles. You'd query the database for all articles ... WHERE featured = 1 LIMIT 3 ORDER BY publishing_date DESC, then loop through the database result set and output all found articles.
That would work, yes. However, this has the overhead of filling a potentially huge array with all the articles from your DB and then iterating through it to pick the featured ones.
For this kind of task, it's better to have the DB filter the results before sending them to PHP.
In general, try to do all your filtering of data in the database, as database are specially optimized for such queries. Loading them into PHP and then filtering the records is slower and less efficient.