Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    formatting mysql result

    hello I just want to ask anybody who has an idea with regards in formating the display of mysql result.

    Attached files are the format(report.jpg) which I want to change to another format (reportformat.jpg)






    Thanks a lot..
    Attached Thumbnails Attached Thumbnails formatting mysql result-report.jpg   formatting mysql result-reportformat.jpg  

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Use a control break to hold off outputing record until you've fetched all of the rows for that record.

  • #3
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    do u have any example? of control break?


    the structure of my table is below..
    event_id | action_type | updatedby| updatedlast`
    1 | 15 | 2 | date
    2 | 13 | 2 | date
    3 | 15 | 1 | date
    4 | 18 | 1 | date
    5 | 19 | 1 | date


    event id is the primary key.
    Last edited by che_anj; 04-03-2008 at 04:33 PM.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    This will echo each unique last_name in table1. You'll need to flip it a bit to print the previous record info when the name changes.

    PHP Code:
    $query = (SELECT FROM table1 ORDER BY last_name);
    $result mysql_query($query);
    if (!
    $result) {
        die (
    "Query error in $query<br />" mysql_error());
    }

    $prevLastName " ";
    for (
    $i 0$i mysql_num_rows($result); $i++) {
        
    $rowInfo mysql_fetch_assoc($result);
        if (
    $rowInfo['last_name'] > $prevLastName) {
            echo 
    $rowInfo['last_name']."<br />";
            
    $prevLastName $rowInfo['last_name'];
        }


  • #5
    New Coder
    Join Date
    Aug 2007
    Posts
    26
    Thanks
    0
    Thanked 4 Times in 4 Posts
    PHP Code:
    <?php
    $sql1 
    "SELECT updatedby FROM eventss GROUP BY updatedby";
    $res1 mysql_query($sql1);
    while (
    $row1 mysql_fetch_assoc($res1)) {
        echo 
    "<p>=by=".$row1['updatedby']."=by= ";
        
    $sql2 "SELECT action_type FROM eventss WHERE updatedby = $row1[updatedby]";
        
    $res2 mysql_query($sql2);
        while (
    $row2 mysql_fetch_assoc($res2)) {
            echo 
    " =action=".$row2['action_type']."=action= ";    
        }    
    }     
    mysql_close($link);


    ?>
    Last edited by Bahamut; 04-03-2008 at 04:55 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •