|Interfacing uShop with MySQL|
|Interfacing uShop with MySQL|
Author Microburst Support Team on 11-02-2001 at 21:00 (EST)
|If you are tired of maintaining hundreds of product pages that contain uShop applets, you might consider putting your products in a database, and then dynamically generating your HTML pages containing uShop applets. If you know something about programming, you might be interested in getting familiar with PHP, an open-source language that can work with a MySQL database. Most web-hosting providers who support MySQL will have PHP installed as well for their customers to use freely. There is a good reference site at http://www.php.net to help you get started. |
Depending on your programming skills, you could consider writing yourself some PHP code that reads your "producttable" and then dynamically populates product pages and your uShop applet options.
For example here is a loop written in PHP which connects to a MySQL database, accesses a "product table" looking only for products with a quantityavailable greater than zero, and then only prints out an applet for each of those products. You should notice that in this example I jump in and out of PHP with the symbols. FYI caution - this example does not include any error checking/handling:
// connect to your MySQL database
$db_socket = mysql_connect("yourhost.com","user","password");
// select only products which have a quantity
// available greater than 0 in your database
// (This assumes you have a table which is keeping
// track of your inventory, of course.)
$q = "select * from yourproducttable where qtyavailable > 0";
$qresult = mysql_db_query("yourdatabasename",$q,$db_socket);
while($row = mysql_fetch_object($qresult))
// here is a snippet of an applet, i left the
// rest of the applet out for brevity and made
// up some field names for this product table
} // end while loop
I am just suggesting one free solution, but there are no doubt other ways of interfacing a database with HTML pages containing uShop applets. I've also seen this done with ColdFusion and an Access database.
Microburst Technologies Support Team
|Messages In This Discussion|
| 1. PHP MySQL Suggestion Works!|
Author Brian Levine on 11-02-2001 at 21:03 (EST)
|Wow! This is fabulous! I keep all of the tag info for my catalog in one table, along with image path and size, and using just a few basic page templates, I only have to change the id data in the query for each item. If qty = 0 in the table then it displays the out of stock message instead of the item applet.|
Not only will this help me to update my catalog a lot easier, but it makes it simple to add new pages.
You need to include something about this in your docs. Almost all Unix hosts support PHP and MySQL.
Check out this link for a sample page:
(this posting was copied from Brian's original post at this link: http://www.uburst.com/dcforum/ushop_prog_tips/101.html )
| 2. PHP Sample Code|
Author Microburst Technologies Support Tea on 11-14-2001 at 19:21 (EST)
|If you try to view this message thread using Netscape, you might not be able to see the sample code in the above posting. |
If you do not have another browser available, e-mail us at email@example.com and we can e-mail you some sample PHP code.
| 3. Getting Started with PHP|
Author Microburst Technologies Support Tea on 11-14-2001 at 19:35 (EST)
|One important point I forgot to mention, if you include PHP code in a web page, you will need to change the extension of that web page to be either |
depending on the version of PHP that is installed on your server.
| 4. DB uShop with MySQL/Php ...|
Author James - Hampton Development on 11-19-2001 at 21:34 (EST)
I developed a complete admin for mysql and php which interface with uShop. Sorry, not for sale, only for licensed installs for domain sites, single users. Not for resale. It can be done very easily, just takes time to configure a scheme that will satisfy many different merchants. It's really the only way to do it, even for small sites.
(Currently 6,800+ CD Titles)
More can be found from our site, working pretty much the same:
I have them set up with cross selling options, several dynamic options, availability options, pass protected wholesale as well as retail output, specials posted to front page, tons more. Here is an old db demo template (inactive), several new options have been added.
It's been a process from input of several merchants needs over time.
I've been using uShop for quite some time, it's the perfect marriage for database setup, merchants have freedom to admin completely themselves with many options.
Bill Weiner has also been a big support..;) These folks are tops!
| 5. msaccess example?|
Author oliver on 03-19-2002 at 19:03 (EST)
|I would appreciate if you could explain how to do this using access with one of the codepieces that I have downloaded with Ushop? I have the database working in FrontPage. At the moment it is giving me an ASP table as output. ... Many thanks!
| 6. Integrating w/Access|
Author Brian Levine on 03-20-2002 at 08:52 (EST)
|Just to clarify...you are running on a Windows NT server and wish to use Access as your server-side database (I could debate the wisdom of this for a while,but I'll refrain). You want to create web pages that will integrate with this database, and you plan on using Active Server Pages to accomplish this.|
Is this correct?
| 7. Integrating with access|
Author oliver on 03-20-2002 at 13:06 (EST)
|Yup! In South Africa we do not have much choice...|
The server has frontpage extensions. NO PHP or unix etc. I have one of your examples downloaded. I obviously want to replace the TAG hell with refrence to something that I can use. I will ALLWAYS be downloading the full database file so SQL is easy. This at the moment is downloaded s ASP with your java tag replicated on each line - More than sufficient for my purposes. The prob is that I now need access to the item data on the left line in ASP or someother way?
| 8. ASP to Access|
Author Brian Levine on 03-22-2002 at 12:32 (EST)
|Well, I'm no ASP programmer, but I think that the same structure I used would apply: You're going to need an ODBC connection to your database, and then you'll have to supply the ASP code to access the DB from your pages. Look at this PHP code snippet from my example:|
// $q - sql string
// $idno - id of item in database
// $dbs - the database socket
// $cs - colspan value (defaults to 1)
$q = "select * from catalogue where Id = '" . $idno . "'";
$db = mysql_select_db("my_odbc_conn",$dbs);
$result = mysql_query($q);
$row = mysql_fetch_object($result);
The technique is fairly straightforward:
- connect to the database
- query the database
Your challange is to figure out how to do this using ASP, and then to teach the rest of us
I would like to see the good folks at uBurst to add all this info to the uShop documentation (along with the sample code). I think that a lot more people would use this approach if they knew that they could do it fairly easily (and if you have more than 10 pages of catalog items, you're crazy not to). Moreover, its the only way I know of to integrate uShop into an Inventory/Invoicing system.