include 'inc.php';
$varVeh=$_POST['Veh_num'];
$sql_course="select course_num from hc_course";
$results_course=mysql_query($sql_course);
$sql_vehName="select Veh_name from hc_vehicle_type where Veh_num=$varVeh ";
$result_vehName = mysql_query($sql_vehName);
$vehName=mysql_fetch_assoc($result_vehName);
echo "<table><tr><th>Best Scores for".$vehName['Veh_name']."</th> </tr></table>";
while($rc = mysql_fetch_array($results_course)){
$sql_HiScores = "SELECT c.course_name as course, e.distance as distance, e.score as score, e.time as time, e.user as User from hc_entries e left join hc_course c on e.course=c.course_num WHERE c.course_num=".$rc['course_num']." and e.vehicle=$varVeh ORDER BY course, score DESC Limit 3 ";
$result_HiScores = mysql_query($sql_HiScores);
?>
<table border='1'>
<tr>
<th>Course</th>
<th>Score</th>
<th>Distance</th>
<th>Player</th>
<th>Time</th>
</tr>
<?php
while($row = mysql_fetch_array($result_HiScores))
{
echo "<tr>";
echo "<td>" .$row['course'] . "</td>";
echo "<td>" .$row['score'] . "</td>";
echo "<td>" .$row['distance'] . "</td>";
echo "<td>" .$row['User'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
目前,这是在页面下创建表格。我想知道是否有办法并排获得2张桌子:
表1表2 表3表4 表5表6
如果它们适合页面,甚至可能是3。
表1表2表3 表4表5表6
答案 0 :(得分:1)
添加到页面的开头:
<script type="text/css">
table{
width: 30%;
margin: 2%;
float: left;
}
</script>
你可能不得不玩边缘,或者你可能根本不需要它们,但那应该放在彼此旁边的3张桌子
答案 1 :(得分:1)
将结果包装在另一个表格中。
echo "<table>";
$count = 0;
$num_columns = 2; // or 3
while ($rc = mysql_fetch_array($results_course)) {
if ($count++ % $num_columns == 0) {
echo "<tr>";
}
echo "<td>";
// previous table code here
echo "</td>";
if ($count % $num_columns == 0) {
echo "</tr>";
}
}
if ($count % $num_columns > 0) {
echo "</tr>";
}
echo "</table>";