SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Merging results?

    Hello,

    I was wondering if I could merge my results from my MySQL table?

    e.g



    It takes the normal results it would get (Master Set). Then the second set alters the master set, but it cannot set 1 to 0, only 0 to 1 to produce the master set.

    Note: They are results are from the same table and there can be a unlimited number of columns and results.

    Is there a way I can do this using my SQL query or will I have to manually code the script?

    Thanks,

    Tom

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    please post the queries that you use to retrieve the master set and the second set.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    # First Query with Master Table

    $data mysql_fetch_assoc($result);

    # Second Query

    $row mysql_fetch_assoc($result);

    foreach (
    $data as $key => $value) {

        if (isset(
    $row[$key]) && $row[$key] > 0) {
            
    $data[$key] = $row[$key];
        }

    }
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

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