Jay Blanchard wrote:
[snip]
I have a MySQL table with four columns - userid, created_date, username and path_to_picture. path_to_picture column contains the path to the image files of those users who have uploaded pictures. An example path stored in path_to_picture column is picture/username.png. There are some users that don't have their pictures uploaded. The column contains

nothing for these usernames.

I want to generate an HTML table with 20 recent users who have uploaded their pictures. Each row in the HTML table should contain 5 columns. Thus the HTML table would contain 4 rows.

How can I accomplish this?

I hope I have provided enough information to describe my problem. I would be glad to provide more details if required.

I tried few permutations and combinations with ORDER BY and LIMIT clauses to no avail. I have been scratching my head from few hours to get this to work. Any help would be greatly appreciated.
[/snip]

SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY
created_date LIMIT 20





Then to take this to the next step


<?php

...
...

$SQL = 'SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY 
created_date LIMIT 20';

$results = mysql_query($SQL);

if ( $results && mysql_num_rows($results) > 0 ) {
        echo '<table><tr>';
        echo '<th>&nbsp;</th>';
        echo '<th>User ID</th>';
        echo '<th>Date Created</th>';
        echo '<th>Username</th>';
        echo '<th>Picture</th></tr>';
        
        $id = 1;
        while ( list($userid, $created_date, $username, $path) = 
mysql_fetch_array($results) ) {
                echo '<tr>';
                echo '<td>'.($id++).'</td>';
                echo '<td>'.$userid.'</td>';
                echo '<td>'.$created_date.'</td>';
                echo '<td>'.$username.'</td>';
                echo '<td><img src="'.$path.'" /></td>';
                echo '</tr>';
        }
        echo '</table>';
} else {
        echo 'No results found';
}

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to