我有json编码的字符串,我转换为php / html表,但它不起作用。
foreach : invalid argument
html应该是:
id text date
1 NY John 9999999 yyyy/mm/dd hh:mm
代码:
<h2 class="title-list">Vle Data List</h2>
<div class="vlist" style="margin:10px auto; width:95%;">
<table border="1" cellpadding="5" cellspacing="0" id='list' width="100%">
<tr class="tblhead">
<th>S.No.</th>
<th>Text</th>
<th>Date</th>
</tr>
<?php
global $wpdb;
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
$limit = 100; // number of rows in page
$offset = ( $pagenum - 1 ) * $limit;
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM wp_data" );
$num_of_pages = ceil( $total / $limit );
$entries = $wpdb->get_results( "SELECT * FROM wp_data LIMIT $offset, $limit");
foreach($entries as $print) {?>
<td><?php $print->id; ?></td>
<td>
<?php
$json= $print->text;
json_decode($json);
$vledata =json_decode($json, true);
echo "<table>";
foreach ($vledata as $key => $value)
{
echo "<tr>". $key ."</tr>";
echo "<tr>". $value . "</tr>";
}
echo "</table>"; ?></td>
<td><?php $print->data; ?></td>
<?php } ?>
</table>
</div>