two sql queries in one place

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-05-20T12:01:03Z Indexed on 2010/05/20 12:10 UTC
Read the original article Hit count: 162

Filed under:
|
        <?php
    $results = mysql_query("SELECT * FROM ".TBL_SUB_RESULTS."
                           WHERE user_submitted != '$_SESSION[username]' AND home_user = '$_SESSION[username]' OR away_user =   
                           '$_SESSION[username]'  ") ;
    $num_rows = mysql_num_rows($results);
        if ($num_rows > 0)
        { 
            while( $row = mysql_fetch_assoc($results)) 
            {
                extract($row);
                $q = mysql_query("SELECT name FROM ".TBL_FRIENDLY." WHERE id = '$ccompid'");
                while( $row = mysql_fetch_assoc($q)) 
                {
                    extract($row);
                ?>
                    <table cellspacing="10" style='border: 1px dotted' width="300" bgcolor="#eeeeee">
                    <tr>
                    <td><b><? echo $name; ?></b></td>
                    </tr><tr>
                    <td width="100"><? echo $home_user; ?></td>
                    <td width="50"><? echo $home_score; ?></td>
                    <td>-</td>
                    <td width="50"><? echo $away_score; ?></td>
                    <td width="100"><? echo $away_user; ?></td>
                    </tr><tr>
                    <td colspan="2"><A HREF="confirmresult.php?fixid=<? echo $fix_id; ?>">Accept / Decline</a></td>
                    </tr></table><br>
                    <?
                }


            }


        }
        else
        {
            echo "<b>You currently have no results awaiting confirmation</b>";
        }

    ?> 

I am trying to run two queries as you can see. But they aren't both working. Is there a better way to structure this, I am having a brain freeze! Thanks

OOOH by the way, my SQL wont stay in this form! I will protect it afterwards

© Stack Overflow or respective owner

Related posts about php

Related posts about sql