1

enter image description here

when select data from database using php-mysql and display in html table it shows as (A).

but i want to display it as (b)

help me...

1 Answers1

3

Sample (and very simple) code would be:

// assuming the PDO connection is established and kept in $db
$st = $db->prepare("SELECT Date, Num, Value1, Value2 FROM the_table");
if ($st->execute()) {
    $previousDate = NULL;
    $previousNum = NULL;
    while ($row = $st->fetch()) {
        echo '<tr>';
        echo '<td>';
        if ($previousDate != $row['Date']) {
            echo $row['Date'];
            $previousDate = $row['Date'];
        }
        echo '</td>';
        echo '<td>';
        if ($previousNum != $row['Num']) {
            echo $row['Num'];
            $previousNum = $row['Num'];
        }
        echo '</td>';
        echo '<td>'. $row['Value1'] .'</td>';
        echo '<td>'. $row['Value2'] .'</td>';
        echo '</tr>';
    }
}
Sergey Vidusov
  • 1,342
  • 1
  • 7
  • 10