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 Code:
$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.
You can add in forum block also ....
Create New Forum Block with PHP selection and cut paste the below code --- Remember to change symbol as per your requirement
PHP Code:
$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>";
check the workinghttp://www.gsnindia.com/content/