Skip to content Skip to sidebar Skip to footer

Set Tables As Side By Side Instead Of Straight Down While Doing A While-loop

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_veh

Solution 1:

Wrap the result in another table.

echo"<table>";
$count = 0;
$num_columns = 2;  // or 3while ($rc = mysql_fetch_array($results_course)) {
    if ($count++ % $num_columns == 0) {
        echo"<tr>";
    }
    echo"<td>";
    // previous table code hereecho"</td>";
    if ($count % $num_columns == 0) {
      echo"</tr>";
    }
}
if ($count % $num_columns > 0) {
  echo"</tr>";
}
echo"</table>";

Solution 2:

Add the to the head of the page:

<script type="text/css">
  table{
    width: 30%;
    margin: 2%; 
    float: left;
  }
</script>

You may have to play around with the margins, or you may not need them at all, but that should put 3 tables next to eachother

Post a Comment for "Set Tables As Side By Side Instead Of Straight Down While Doing A While-loop"