Question by Mark C: Update product prices using PHP/mySQL?
We have a website with about 100 products that can be bought online using a shopping cart (which uses html forms and perl scripts).
The site is static HTML so we have full control over search engine optimisation.
However, as you can imagine it becomes a right pain in the ass updating prices.
Can anyone give me any pointers on how to update the prices using PHP and a mySQL database.
The way I envisage it working is that each of our 100 product pages (currently html) will become php. Where the price should be in the source code I will put a php function echo to insert the price for the product. If it helps all products have a unique number that could be used to reference the mySQL database.
Although I sort of understand how it should work, I could do with a few pointers on how to implement this. Any pointers would be greatly appreciated.
I also presume that I will be able to up/download data to the mySQL database using a correctly formatted CSV file, rather then having to code/design an admin section as well (as it will be only myself doing the updating)?
Answer by J P
I think it would make more sense, to have each of the products (name, description, price, photos) stored in the database, then just use PHP to query the database and display the information. If you are going to use dynamic tools like PHP and MySQL, it seems like a waste to hard-code information (like prices) into the PHP page, that wouldn’t be much different that hard-coding them into an HTML page.
To get started, I would create a database table that contains your products. Then I would write some PHP to query that database and retrieve that product information. After you’ve got the data retrieval part down, then think about how to restructure the HTML as PHP, to use the dynamic data.
It sounds like you’ve got a lot of work ahead of you, good luck 🙂
Add your own answer in the comments!
There are no revisions for this post.