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");
you are done.
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.