Stock market Status

Admin

AdminAdmin is verified member.

Well-Known Member
Staff member
Administrator
Create New Widget for PHP direct Execution It shows stock market status

copy and paste the following code and place

just change the array symbol as per your requirement. $Arraysymbol = array("NSE:NIFTY", "NSE:CNXMIDCAP", "NSE:CNX500","NSE:CNX100");

PHP:
$Arraysymbol = array("NSE:NIFTY", "NSE:CNXMIDCAP", "NSE:CNX500","NSE:CNX100");
//Obtain Quote Info - This collects the Microsoft Stock Info
$output .="<style>
thead {color:green;}
tbody {color:blue;}
tfoot {color:red;}
table,th,td
{
border:1px solid black;
}
</style>";
 $output .= "<table><thead><tr>
      <th>Index</th>
      <th>Current</th>
	  <th>change</th>
	  <th>Percent</th>
    </tr>
  </thead>
 <tbody>";
 foreach ($Arraysymbol as $i => $value) {
  
 $quote = file_get_contents('http://www.google.com/finance/info?infotype=infoquoteall&q='. $Arraysymbol[$i]);
   //Remove CR's from ouput - make it one line
  $json = str_replace("\n", "", $quote);
  
  //Remove //, [ and ] to build qualified string  
  $data = substr($json, 4, strlen($json) -5);
    //decode JSON data
  $json_output = json_decode($data, true);
   $output .= "<tr><td>". $json_output['name']. "</td><td>".  $json_output['l'] . "</td><td>".  $json_output['c'] . "</td><td>".  $json_output['cp'] . "</td></tr>";
  
}
 $output .= "  </tbody>
</table>";

you are done.
 

Facebook Comments

Similar threads

cuongpro9x
Replies
0
Views
874
cuongpro9xcuongpro9x is verified member.
cuongpro9x
Admin
Replies
2
Views
1K
nhokzodanh
nhokzodanh
Admin
Replies
0
Views
2K
AdminAdmin is verified member.
Admin
Admin
Replies
2
Views
4K
aodoidep87
A
Admin
Replies
0
Views
931
AdminAdmin is verified member.
Admin
Admin
Replies
0
Views
847
AdminAdmin is verified member.
Admin
Admin
Replies
0
Views
2K
AdminAdmin is verified member.
Admin
Back
Top