Is there a way to duplicate Excel's web query tool in PHP? I currently use Excel to get stock quotes from the MSNMoney site. I would like to be able to get stock quotes from the web to incorporate in a PHP/MySQL investment tracking system.

    I'm not sure how Excel's web query tool works, but in PHP, you can use fopen() to open a web page (the page with stock quotes, for example), and then use the string and/or regular expression functions to strip the quotes from the HTML code.

    Diego

      You'll need to make sure ODBC connectivity is enabled, then create a connector on the windows box for the MySQL server. Then, Excel should be able to "see" the server and query it.

        Thanks. I got it to work using fopen() and fgets(). It took me a long time to figure out a loop to keep checking the lines until the right string appeared. I am getting the quotes from http://quote.money.cnn.com/quote/quote.

        This solution, however, would have to be rewritten to get data from any other page. Excel web queries lets you select any table on a web page and import the complete table into Excel format.

          Write a Reply...