1

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

      }
3
  • 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. Commented Jan 5, 2015 at 17:26
  • If you load the details immediately, how will the user fill in the form to enter the symbol? Commented Jan 5, 2015 at 17:27
  • 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 automatically Commented Jan 5, 2015 at 17:30

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

10 Comments

It still does not pull information from the yahoo website depending on the symbol
what response you are getting?
the response I am getting is the same webpage as before. Yet If I click on the update button it updates the information being pulled from yahoo website. so I am wondering If I can create a function in which I can use the following code if so how . also the code I am referring to is the one posted on top of page
Please share the code of page in which you have update button
elseif(isset($_POST['a_update'])){ //scan yahoo finance for recent data $symbol = $_POST['symbol']; $header = "Searching Yahoo! for updated information for ".$symbol."."; $ppe = $_POST['ppe']; $revenue = $_POST['revenue']; $income = $_POST['income']; $market_cap = $_POST['market_cap']; $depreciation = $_POST['depreciation']; $rate_of_return = $_POST['rate_of_return']; $rate_of_return_w_ppe = $_POST['rate_of_return_w_ppe']; $debt = $_POST['debt'];
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.