在数据表中以两列显示数据
我已设法在一列表中显示数据,但希望有两列。有办法做到吗?这是我目前拥有的代码。虽然它可以工作,但它会打印一长列,并希望将其分成两列。
如您所知,我正在使用 jQuery Datatable。
<?php
include('config.php');
mysql_connect($host, $username, $password) or die(mysql_error()) ;
mysql_select_db('people') or die(mysql_error()) ;
$data = mysql_query("SELECT * FROM names ORDER BY RAND() LIMIT 20") or die(mysql_error());
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="datatables/dt/media/js/jquery.dataTables.js">
</script>
<style type="text/css">
/* @import "datatables/dt/media/css/demo_table.css";
.result_container{
width: 553;
} */
</style>
<script>
$(document).ready(function(){
$('#the_table').dataTable();
});
</script>
</head>
<body>
<?php
echo "<table id=\"the_table\">
<thead>
<tr>
<th>Latest names</th>
</tr>
</thead>
<tbody> ";
while($info = mysql_fetch_array( $data )){
echo"<tr> <td>" . $info['name'] . "</td>
</tr>";
}
echo" </tbody> ";
echo "</table> ";
?>
</body>
</html>
任何帮助将非常感激。
I have managed to display data in one column table, but would like to have two column instead. Is there a way of doing it? Here's the code I currently have. Although, it works, it prints in one long column and would like to break it into two columns.
As you can tell, I'm using jQuery Datatable.
<?php
include('config.php');
mysql_connect($host, $username, $password) or die(mysql_error()) ;
mysql_select_db('people') or die(mysql_error()) ;
$data = mysql_query("SELECT * FROM names ORDER BY RAND() LIMIT 20") or die(mysql_error());
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="datatables/dt/media/js/jquery.dataTables.js">
</script>
<style type="text/css">
/* @import "datatables/dt/media/css/demo_table.css";
.result_container{
width: 553;
} */
</style>
<script>
$(document).ready(function(){
$('#the_table').dataTable();
});
</script>
</head>
<body>
<?php
echo "<table id=\"the_table\">
<thead>
<tr>
<th>Latest names</th>
</tr>
</thead>
<tbody> ";
while($info = mysql_fetch_array( $data )){
echo"<tr> <td>" . $info['name'] . "</td>
</tr>";
}
echo" </tbody> ";
echo "</table> ";
?>
</body>
</html>
Any help will be appreciated very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
?>
?>
只需在 HTML 中添加另一个单元格?
Just add another cell in HTML?