I wonder if anyone can help me with a basic MySQL/PHP output problem please.

I have a table called 'Recommendations' which has a small number of fields (id, recom_date, recom_name, recom_status and recom_size).

I want to be able to show the 'recom_status' field as a heading with the other fields lsited below each heading. If the recom_status fields contain only 'Final', 'Draft' and 'Withdrawn' I want the display to look like this

name date size
name date size

name date size
name date size

name date size
name date size

I believe that the MySQL is something like:

SELECT * FROM 'Recommendations' ORDER BY 'recom_status', recom_name';

but I don't have a clue how to display this using PHP

Any help will be greatly appreciated

This should get you started.

$connection = mysqli_connect('host','username','password','database_name');

$sql = "SELECT * FROM recommendations ORDER BY recom_status, recom_name";

$query = mysqli_query($connection, $sql);

$results = mysql_fetch_assoc($query);

<?php foreach($results as $result): ?>
<h3><?php echo ucfirst($result['recom_status']; ?></h3>
        <td><?php echo $result['recom_name']; ?> </td>
        <td><?php echo $result['recom_date']; ?></td>
        <td><?php echo $result['recom_size']; ?></td>
<?php endforeach; ?>
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.