Jump to content

harcheng

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by harcheng

  1. Oh wait, I got it! Just changed the code to: echo '<table>'; echo '<tr>'; while($row = mysql_fetch_assoc($result)) { if($lastrow != $row['row']) { echo '</tr><tr>'; } echo '<td>'.$row['id'].'-'.$row['row'].$row['col'].'</td>'; $lastrow = $row['row']; } echo '</table>'; Thanks again!
  2. Hey Psy, thanks for the really quick reply. I get what you mean and you're correct, that's exactly what I need. I'm trying to write it in a different way though - I don't know why this won't output a multi-row table: echo '<table>'; echo '<tr>'; while($row = mysql_fetch_assoc($result)) { if($lastrow = $row['row']) { echo '<td>'.$row['id'].'-'.$lastrow.$row['col'].'</td>'; } else { echo '</tr><tr>'; } $lastrow = $row['row']; } echo '</table>'; I thought that the '$lastrow = $row['row'];' line would help identify the change in the value of 'row'. Might you know what's wrong? Thanks!
  3. Hi guys, is there anyway to process this $result from a mysql query inside PHP so that the data below will be formatted to a pivot-like table? The number of rows and columns of the output 'table' will be indefinite. Thanks so much! Data: ID Row Col Name 1 1 A A1 2 2 A A2 3 3 A A3 4 1 B B1 5 2 B B2 6 3 B B3 7 1 C C1 8 2 C C2 9 3 C C3 Results: A1(1) A2(2) A3(3) B1(4) B2(5) B3(6) C1(7) C2( C3(9)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.