Hi All,
This has become a very tedious process and I am hoping someone can help me simplify things.
I run the below php command to retreive all the stock prices and then it prints it to the screen like this:
stockcode price
AAA $1
BBB $2
CCC $3
It takes about 5 minutes to get the 2000 results and then I have to paste it into excel and use cancatenate strings to generate my sql insert query. It all works perfectly but I would love to somehow do the sql insert automatically after running the script below.
<?php
$url = "http://asx.com.au/asx/markets/priceLookup.do?by=asxCodes&asxCodes=ONT";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$var = curl_exec($ch);
curl_close($ch);
$first = stripos($var, '<th scope="row" class="row"><a href="/asx/research/companyInfo.do?by=asxCode&asxCode=', 0) ;
$second = stripos($var,'<td class="change indicator" nowrap>', 0);
echo substr($var, $first, $second - $first);
echo "<br />";
$url ...
$url ...
?>
Ideally, I just want to open the php page and it will retreive the codes/prices and then automatically inserts it into the DB. My current insert query is below.
INSERT INTO ASX_PRICES
(ASX_CODE
, ASX_PRICE
, DATE
) VALUES ('ONT', '5.43' '2013-01-03')
INSERT INTO ...
INSERT INTO ...
Thanks.
Matt.