Joe and Nancy ([EMAIL PROTECTED]) writes:
> I am in a time crunch to get mysql working on my site. I export inventory
> records out of my Peachtree software into Excel and planned to use that .xls
> table to show product pricing and availability on my web pages. Below is
> sample asp code that works. My ISP had told me they support asp, but after
> coding and testing (at another site), I found that my ISP really doesn't
> support asp. Can anyone provide a sample chunk of mysql code that would do
> what this asp code does...
First, doing this from a spreadsheet is a very innificient way of doing things (for a
lot of reasons). Second, MySQL won't allow you to directly connect to a spreadsheet -
it only talks to a MySQL database.
I will assume you mean that you want to pull records out of a database and display
them on a web page - if that is a safe assumption to make, here's a little Escapade
code to do what you want (Escapade is a SSL that sits on top of MySQL). Perl/PHP code
is more complicated, but does essentially the same thing:
> <%@ Language=VBScript %>
> <%Option Explicit%>
> <%
> 'Declare Variables
> Dim cnnExcel, rsProduct, strSQL
> 'Connection Object
> set cnnExcel = server.createobject("ADODB.Connection")
> cnnExcel.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ=" &
> server.MapPath("../catalog.xls") & ";"
> 'RecordObject
> set rsProduct = server.CreateObject("ADODB.recordset")
> %>
<DBOPEN "mysql", "localhost", "login", "password">
> Next to each product is this code, it shows the price and qty from the file
> and an image with a hyperlink if qty > 0:
>
> <%
> 'Code for checking inventory
> 'SQL
> strSQl = "SELECT * FROM [Sheet1$] WHERE ((([Sheet1$].[Product
> Code])='blizzard'))"
> 'Open Recordset
> rsProduct.Open strSQl, cnnExcel
> if not rsProduct.EOF then
> Response.Write "Price: $" & rsProduct.Fields("Price").Value & "<br><br>"
> Response.Write "Quantity on Hand: " & rsProduct.Fields("Qty in
> Stock").Value & "<br><br>"
> if rsProduct.Fields("Qty in Stock").Value > 0 then
> Response.Write "<a href=""url here""><img src=""images/button.gif""></a>"
> end if
> end if
> %>
<SQL select * from table where Product_Code='blizzard'>
# this code will get skipped if there are no records in the recordset
Price: $Price<br><br>
Quantity on Hand: $Qty_in_Stock<br><br>
<IF "$Qty_in_Stock" GT "0">
<a href="url"><img src="images/button.gif"></a>
</IF>
</SQL>
--
Ed Carp, N7EKG [EMAIL PROTECTED] 940/367-2744 cell phone
http://www.pobox.com/~erc [EMAIL PROTECTED] - text pager
I sometimes wonder if the American people deserve to be free - they seem
so unwilling to fight to preserve the few freedoms they have left.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php