我试图创建一个成员列表,其中数据库中的所有用户都将显示在表中,并且每个表将包含他们的名称下的配置文件链接。在php(会员列表)中从mysql创建表链中的链接
,但我得到致命错误:无法使用类型stdClass的对象作为数组
这里是我的代码
mysql_select_db('members',$connection) or die(mysql_error());
//执行MySQL查询到从用户表中检索所有用户
$query=mysql_query("SELECT * FROM members") or die(mysql_error());
//如果我们得到任何结果,我们向他们展示在表中的数据
if(mysql_num_rows($query)>0):
<table cellspacing="0" id="tech-companies">
<thead>
<tr>
<th class="persist essential">Name</th>
<th class="essential">Status</th>
<th class="essential">Balance</th>
<th class="essential">Balance Updated</th>
<th class="optional">Member Type</th>
<th class="optional">Mobile</th>
<th class="optional">Gender</th>
<th class="optional">ID</th>
<th class="optional">Last Logged in</th>
</tr>
</thead>
<tbody>
<?php
//while we going through each row we display info
//echo $row['id'];
while($row=mysql_fetch_object($query)):?>
<tr>
<th align="center">
<?php
----这里是我试图向用户显示的链接...
echo $row->name; echo'<br/><span><a href="#">edit</a> |
<a href="id=' . $row['id'] . '">view</a></span>'; //row id ?></th>
----而持续工作正常..
<td align="center"><?php echo $row->locked; ?></td>
<td align="center"><?php echo $row->balance; ?></td>
<td align="center"><?php echo $row->lbu; ?></td>
<td align="center"><?php echo $row->mcat; ?></td>
<td align="center"><?php echo $row->mobile; ?></td>
<td align="center"><?php echo $row->sex; ?></td>
<td align="center"><?php echo $row->id; ?></td>
<td align="center"><?php echo $row->lastlogin; ?></td>
</tr>
<?php endwhile;?>
</tbody>
</table>
<br/>
<?php
//if we can't get results we show information
else: ?>
<h3>No Results found.</h3>
<?php endif; ?>
我需要学习如何回答得更快。 –
这被称为厄运;) – ryrysz
他他... :)谢谢配对.. – Yush