Tuesday, June 24, 2008

PHP

I have been working with PHP at home lately. Currently I generate my web site as static html pages using Smalltalk (the best programming language ever created).
One problem we have, though, is that we have a lot of products and we run out of inventory, causing back orders.

So, I have been prototyping having my page generator create PHP pages instead, which will create product rows by reading a MySql database each time the page is loaded. If the inventory level is below a threshold, the product row will show "Out of Stock".

The cool thing is that the shopping cart service I uses (mals-e.com) can do a silent post back of order information to a php script, so I plan to use that function to automatically decrement inventory.

One of the trickiest things is getting it to work on my local Apache server, while still reading the database that sits on my hosting account. I had to tweak the Apache config settings, and tweak the PHP config settings. The PHP database connection settings are different depending on which platform you are running on. Fortunately you can detect this pro grammatically, so I can run the same PHP code base on my windows XP machine running apache and on my Linux hosting account.

The design is not perfect; returns and exchanges have to be handled manually etc.

I have built the MySql product table and the table that links products to pages. I have also started prototyping a C# desktop application to allow table maintenance: adjusting prices, removing products from pages etc. The tough part was getting the connection to MySql and the datagrid to display and update rows. That took a couple hours to figure out. Still a lot left to do.

It is kind of ambitious, but it will give us some big benefits like being to run reports of products we are running low on, and drastically reducing the number of back orders we have to deal with.