【发布时间】:2014-06-12 23:19:50
【问题描述】:
这是我的代码,它也与数据库连接,但看到图像,为什么它显示 2 次相同的 ID 和其他行?
这是它所显示的屏幕截图:/
<?php
$username = $_SESSION['usr'];
// get results from database
$result = mysql_query("SELECT * FROM playlist, tz_members WHERE Byuser='$username'")
or die(mysql_error());
echo "<table id='table_example'><thead>";
echo "<tr><th width='1%'>ID</th><th width='10%'>Kengtar(<i><span style='color: blue'>i</span></i>/<i>ja</i>)</th><th width='5%'>Kenga</th><th width='7%'>Albumi</th><th width='2%'>Data</th></tr>";
echo "</thead><tbody>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
echo '<th>#' . $row['ID'] . '</th>';
echo '<td>' . $row['Kengtar'] . '</td>';
echo '<td>' . $row['Kenga'] . '</td>';
echo '<td>' . $row['Albumi'] . '</td>';
echo '<td>' . $row['Data'] . '</td>';
echo "</tr>";
}
echo "</table>";
?>
谢谢你,如果有人试图帮助我,我是 php codind 的新手:S
【问题讨论】:
-
我们可以获取您的数据库的屏幕截图吗?我猜您在 sql 语句中查询的两个表中都有这些行。
-
当然可以,但我可以在这里解释播放列表有(ID、Kengtar、Kenga、Linku、Data、Byuser),而 tz_members 只有 memberID、用户名密码
-
谢谢你解决了,我只需要从选择中删除 tz_members 我很高兴是的哈哈哈非常感谢你
标签: php database error-handling rows