Json
{"segment":"Class I-V Tuition,Class VI-VIII Tuition"
,"Board":["cbse"]
,"Class I-V":["Allsubject"]
,"Class VI-VIII":["cbse","cse/Ise"]
,"Class VI-VIII Subject":["Allsubject","Science"]
,"Class XI-X":null
,"Class XI-X Subject":null
,"Class XI-XII":null
,"Class XI-XII Subject":null
,"Languagesubject":null
,"engineering":null
,"Diploma":null
,"Dancesubject":null
,"Degree Course":null
,"Degree Subject":null
}
Here key:Board
value:cbse
key:Class I-V
value:Allsubject like wise json pattern stored in classconducted column
My questions are:
- How to retrieve the json string?
I have tried like this.
$sqledit = mysql_query("select * from tinfo where tsname='" .$_SESSION['tutorname'] ."'");
$row = mysql_fetch_array($sqledit);
foreach (json_decode($row['classconducted'], true) as $key => $val) {
if($key!='' && $val!='') {
echo '<span class="details">'.$key.'</span>'.': '."<br/><br/>";
if (is_array($val))
echo implode(',', $val) . "<br/><br/>";
else
echo $val . "<br/>";
}
}
Now I want to edit the page. So using foreach
I separate the values. Here I have decode the json values. now the values are coming . I want to know how to pass the json values to my form. Here is my form. I have tried like this, I don't know what is wrong in my code.
I want ouptut like this: check this is this correct
<input type="checkbox" name="board[]" value="cbse" <?php if($val[0]=='cbse'){echo "checked";}?>>CBSE
<input type="checkbox" name="board[]" value="cse/Ise" <?php if($val[1]=='ICSE/ISE'){echo "checked";}?>>ICSE/ISE.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…