How to load details automatically
Thanks guys and gals got it working
//create a function function get_stock_data($symbol){ //set up the url to be called $revenue_url = "http://finance.yahoo.com/q/is?s=".$symbol;
//curl call: // create a new cURL resource $ch = curl_init();
// set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $revenue_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser $result = curl_exec($ch);
// close cURL resource, and free up system resources curl_close($ch);
//finish by returning the result return $result; }
//REQUEST WILL BE POPULATED IF EITHER GET OR POST IS SET!
$data = null; // this will hold our data, declared here for accessibility
if(isset($_REQUEST['symbol']) && $_REQUEST['symbol'] != ''){
//call our get_data function
$data = get_stock_data($_REQUEST['symbol']);
}
// data returned from our get_stock_data() call.
$ppe = $data['ppe'];
$revenue = $data['revenue'];
$income = $data['income'];
$market_cap = $data['market_cap'];
$depreciation = $data['depreciation'];
$rate_of_return = $data['rate_of_return'];
$rate_of_return_w_ppe = $data['rate_of_return_w_ppe'];
$debt = $data['debt'];
}
Add following code in your update button(page) script at last
<script type="text/javascript">
var php_var = "<?php echo $symbol; ?>";
locationInfo="stock_next.php?symbol="+php_var;
setTimeout(function(){
location =locationInfo
},2000)
</script>
Your page will be automatically updated after some seconds
链接地址: http://www.djcxy.com/p/48580.html下一篇: 如何自动加载细节