我想从mysql'ptb_stats'中的表中获取信息。这是通过特定的'user_id'拉动的,这样每个站点的成员只能看到他们的统计信息。用mysql提取数组显示信息?
到目前为止一切事情是我得到的图像呼应”的页面上,并被拉信息只是说数组?
任何建议在那里我去错了吗?
感谢
这是函数:
function get_stats() {
global $connection;
global $_SESSION;
$query = "SELECT s.location, s.nationality, s.hobbies, s.role, s.friends, s.height, s.weight
FROM ptb_stats s
WHERE user_id = \'$profile_id\'";
$stats_set = mysql_query($query, $connection);
confirm_query($query, $connection);
return $stats_set;
}
这是获取数组:
<?php
$stats_set = get_stats();
while ($stats = mysql_fetch_array($stats_set)) {
?>
<table width="100%" border="0">
<tr>
<td width="13%"><?php echo "<img width=40px heigh=34px src=\"assets/img/icons/stats.png\"/>" ?></td>
<td width="25%"><?php echo " $stats"?> </td>
<td width="13%"><?php echo "<img width=40px heigh=34px src=\"assets/img/icons/stats.png\"/>" ?></td>
<td width="25%"><?php echo " $stats"?> </td>
<td width="13%"><?php echo "<img width=40px heigh=34px src=\"assets/img/icons/stats.png\"/>" ?></td>
<td width="20%"><?php echo " $stats"?> </td>
</tr>
<tr>
<td height="36"><?php echo "<img width=40px heigh=34px src=\"assets/img/icons/stats.png\"/>" ?></td>
<td><?php echo " $stats"?> </td>
<td><?php echo "<img width=40px heigh=34px src=\"assets/img/icons/stats.png\"/>" ?></td>
<td><?php echo " $stats"?> </td>
<td><?php echo "<img width=40px heigh=34px src=\"assets/img/icons/stats.png\"/>" ?></td>
<td><?php echo " $stats"?> </td>
</tr>
</table>
<?php
}
?>
你没有通过$ profile_id getStats函数 – Venu
好的抱歉,我是新来的SQL。我怎么做? –
和你总是呼应<?php回声“$ stats”?>而不是<?php echo $ stats ['location']?>等 – Venu