使用php提取存储为json数组的mysql数据

时间:2015-11-12 05:04:13

标签: php mysql json

名为' Marks'的列中的值在我的数据库中存储为[45,56]。我想将其值提取为45和56。我尝试过如下。但没有单独获得价值。

$result =mysql_query("SELECT * FROM school where StudentID='$ss'") or die(mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
    $Fromtable_CurrMARK= $row['marks']; //getting as [45,56]
    $CurrMark = json_decode( $Fromtable_CurrMARK);
    $mark1 = $CurrMark[0];
    $mark2 = $CurrMark[1];
}

0 个答案:

没有答案