1
votes

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'];

      }
1
Danger: You are using an obsolete database API and should use a modern replacement. You are also vulnerable to SQL injection attacks that a modern API would make it easier to defend yourself from.Quentin
If you load the details immediately, how will the user fill in the form to enter the symbol?Barmar
that's the problem before getting to that webpage the user will click a letter (symbol) from there it would take them to another webpage where it holds all details as it is right now the webpage waits until the user clicks an update button . what I want it to do is that it updates automaticallygoibear

1 Answers

1
votes

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