tags:

views:

104

answers:

1

I have a table and I am displaying its contents using PHP and a while(); I have about three fields in the table that are NULL but can be change, but I want them to still display all the results in my table.

But, it only shows the records with data in EVERY field. Anyone how I can display it? I get a count of the table and it gives me 2, but only displays one.

Any thoughts?

UPDATE ADDED CODE:

<h3>Viewing All Updates</h3>
<h4>Below are all active updates for COTC</h4>
<table>
    <thead>
        <tr>
                <th>Site Name</th>
                <th>Page</th>
                <th>Flag</th>
                <th>Date Sent</th>
                <th>View</th>
        </tr>
    </thead>
    <tbody>
        <?php
    $sql    = "SELECT sname,page_name,date_submitted,u_id,clients.c_id,flag,completed FROM updates INNER JOIN clients ON updates.c_id = clients.c_id INNER JOIN pages ON updates.page = pages.p_id ORDER BY date_submitted DESC";
    $query  = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($query)){
        $completed = $row['completed'];
        if($completed == 1){
                print '<tr class="quiet">'; 
        }else{
                print '<tr>'; 
        }
                print '<td>'.$row['sname'].'</td>'; 
                print '<td>'.$row['page_name'].'</td>'; 
                print '<td>'.$row['flag'].'</td>';
                print '<td>'.$row['date_submitted'].'</td>';
                print '<td class="center"><a href="?c=displayupdate&id='.$row['u_id'].'" title="View update for '.$row['sname'].'" id="'.$row['u_id'].'"><img src="images/page_edit.png" alt="Edit entry!" /></a></td>';
        print '</tr>';
    }
?>
    </tbody>
</table>

Thanks,

Ryan

+1  A: 

Your PHP is correctly printing every row returned. I believe your problem is in the query.

SELECT sname,page_name,date_submitted,u_id,clients.c_id,flag,completed 
FROM updates INNER JOIN clients ON updates.c_id = clients.c_id 
             INNER JOIN pages ON updates.page = pages.p_id
ORDER BY date_submitted DESC

This query will only return a row in updates if it has a matching one in clients and a matching one in pages. If you want the clients or the pages joins to be optional (a updates row that has c_id or page of NULL will still return) change them from INNER JOINs to LEFT JOINs.

Paolo Bergantino
It is going to be other fields that AREN't going to be displayed within my while(); but used else where.
Coughlin
... I'm not sure I'm following
Paolo Bergantino
All my rows in my table with ALL of their fields filled in with data show fine.If the anyone one of the fields has NULL as their value, they will not display using the code I posted.
Coughlin