I want to print out a simple list of names from a mysql database into an html page that is using Bootstrap 3 css.
But rather than have one column with a long list I want to divide up the list in three columns ( on a desktop).
The code below does what I want but is not responsive. If I shrink the page all the names overlap. How can I print out the list in a responsive page (with three colums for desktop and perhaps two for mobile).
Thanks.
<?php
$result = mysqli_query($db_conx,"SELECT count(*) FROM mydatabase"); //Count Records
$row = mysqli_fetch_row($result);
$x=0; //Create a counter to count records that have been echoed.
$num = $row[0];
$sum =($num)/3; //Divide the total number of records by 3
$sql = mysqli_query($db_conx, "SELECT * FROM mydatabase"); //Get records
while($row = mysqli_fetch_assoc($sql)){
$x++; //Add 1 to counter
echo $row['name']; //echo row
echo "</br>";
if ($x>$sum){ //If the number of records already echoed is more than a third of the total then create a new column.
echo "</div>";
echo "<div class=\"col-sm-4\">";
$x=0; //Reset counter
}
} //End while loop
echo "</div>";
?>