在此先感谢,我在表列中有三个薪水数据。我正在使用while循环在视图页面中显示三个薪水值。但我必须将这三个值传递给json中的三个变量,如{salary1:$ sal1,salary2:$ sal2,salary3:$ sal3}。如何单独循环三个薪金值到三个变量如何将数据库中的值传递给php中的json
My code as below:
<table border="1">
<caption><h2>View Registration</h2></caption>
<tr>
<th>Name</th>
<th>Designation</th>
<th>Email</th>
<th>Salary</th>
<tr>
<?php
include('common.php');
$sql = mysql_query("select * from register");
while($row = mysql_fetch_array($sql))
{
?>
<tr>
<td><?php echo $row['name']?></td>
<td><?php echo $row['designation']?></td>
<td><?php echo $row['email']?></td>
<td><?php
$salary = $row['salary'];
echo $salary;
?></td>
<tr>
<?php
}
?>
</table>
当你保存值id数据库,现在你可以使用json_decode,它返回数组,从这个数组,你可以访问这个 –
使用'json_decode($ salary,TRUE)' – jitendrapurohit
没有,只是如果我分开环三个薪金值分为三个变量是足够 –