I'm making a php script in which I want an output as follow. I have this code:
$query_man = query
$output_man = mysql_query($query_man);
if(mysql_num_rows($output_man) > 0){
while ($row = mysql_fetch_assoc($output_manutenzione)){
echo "\t" . $row['hostname'];
echo "\n\t\tTipo Manutenzione: " . $row['type'];
echo "\n\t\tData inizio: " . $row['startdate'];
echo "\n\t\tData fine: " . $row['enddate'];
echo "\n\t\tUtente: " . $row['user'];
echo "\n\t\tMotivo: " . $row['desc'];
echo "\n\t\tStato: " . $row['State'] . "\n\n";
}
where type, startdate, enddate etc. are query fields.
In this way I get an outup like this (e.g.):
Hello1
program
2016-10-13 09:00
2016-10-13 10:00
kevin
test
open
Hello1
program
2016-10-13 13:00
2016-10-13 15:30
john
test
closed
Hello2
program
2016-10-12 11:00
2016-10-13 11:30
susan
test
closed
Hello3
program
2016-10-12 13:00
2016-10-12 15:30
clay
test2
open
Well, I don't understand how to get the following outup:
Hello1
program
2016-10-13 09:00
2016-10-13 10:00
kevin
test
open
program
2016-10-13 13:00
2016-10-13 15:30
john
test
closed
Hello2
program
2016-10-12 11:00
2016-10-13 11:30
susan
test
closed
Hello3
program
2016-10-12 13:00
2016-10-12 15:30
clay
test2
open
i.e. I'd like to group the info with the same hostname. How could I do?