<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="relaxinn"; // Database name
$con=mysqli_connect("$host","$username","$password","$db_name");
if (mysqli_connect_errno($con)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Get number of rows
$categories = array();
$sql="SELECT * FROM books ";
$result=mysqli_query($con, $sql);
while($row=mysqli_fetch_assoc($result))
{
$categories[$row['language']][] = $row['code'];
}
//Start table
echo "<table>";
// any type of outout you like
foreach($categories as $key => $category){
echo "<tr class='altrow' align='left'>";
echo "<th>" .$key.'<br/>'. "</th>";
echo "</tr>";
foreach($category as $item){
echo "<tr class='altrow' align='left'>";
echo "<td>" .$item.'<br/>'. "</td>";
echo "</tr>";
}
}?>
ericko10kip 0 Newbie Poster

diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.