stock ticker

Hi guys,
I need help getting a stock ticker running. I’ve found snippets on the web, but can’t finish it… I barely, not even barely know PHP. Please help… :-[
I have this much:

<?php ///// Replace with Yahoo Finance stock quotes of your choice ////// $raw_stock_data = array('AAPL 200 205', 'BIDU 500 510','RIMM 150 155', 'SNDK 70 72', 'GOOG 500 510','MSFT 30 32','AMD 9 10'); sort($raw_stock_data); ////////////////////////////////////////////////////////////////////////// ?>
<?php foreach ($raw_stock_data as $value) { $results = explode(' ',$value);
                $ticker = $results[0];
                $buy = $results[1];
                $sell = $results[2];
               
                echo "<font color=\"#ffffff\">$ticker </font>";
                echo "<font color=\"#00ff00\">$buy </font>";
                echo "<font color=\"#ff0000\">$sell </font>";
                echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                }

?>

but need to get it to feed information from yahoo finance. I found this to do that part;

<?php // Code by: Don Wilson // Edited: October 24, 2003 class stock { function getLastTrade($symbol) { $file = fopen("http://quote.yahoo.com/d/quotes.csv?s={$symbol}&f=sl1d1t1c1ohgv&e=.csv", "r"); $read = fread($file, 2000); fclose($file); $read = str_replace(""", "", $read); $read = explode(",", $read); return $read[1]; } function getChange($symbol) { $file = fopen("http://quote.yahoo.com/d/quotes.csv?s={$symbol}&f=sl1d1t1c1ohgv&e=.csv", "r"); $read = fread($file, 2000); fclose($file); $read = str_replace(""", "", $read); $read = explode(",", $read); return $read[4]; } function getDateClosed($symbol) { $file = fopen("http://quote.yahoo.com/d/quotes.csv?s={$symbol}&f=sl1d1t1c1ohgv&e=.csv", "r"); $read = fread($file, 2000); fclose($file); $read = str_replace(""", "", $read); $read = explode(",", $read); return $read[2] . " " . $read[3]; } } $stock = new Stock(); echo "
\n";
if(isset($symbols))
{
    $symbols = explode(",", $symbols);
    foreach($symbols as $symbol)
    {
    $change = $stock->getChange($symbol);
    if($change < 0)
      $change = "{$change}";
    elseif($change > 0)
      $change = "{$change}";
    else
      $change = "0.00";
     
        echo "Symbol:            " . $symbol                                        . "\n";
        echo "Last Trade:        " . $stock->getLastTrade($symbol)        . "\n";
        echo "Change:            " . $change            . "\n";
        echo "Date Closed:        " . $stock->getDateClosed($symbol)    . "\n";
        echo "\n";
    }
}
echo "
\n"; ?>

But how to properly use part of that information, or even if it can be done has me lost. Can anyone help?
thanks!
YN

I can see two tasks here: 1) retrieving data from Yahoo Finance, and 2) displaying it in ticker. Is this what you need? So, what script will you use for ticker - I believe this must be some javascript or ajax?
Also, what stocks/info are you going to display in that ticker? I can help you create it, as this task seem interesting to me :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service