tags:

views:

117

answers:

1

hey folks,

I'm fairly new to PHP so am not sure how to do this.

I have records in a database that link to images (profile pictures) that i want to display 5 along and 4 down. How would I do this?

Thanks alot!

Jonesy

+1  A: 

First I would find a decent MySQL Tutorial. Then I would practice running some basic SELECT queries.

After you've done that it's as simple as

$sql = "SELECT `picture_link` FROM `users` WHERE 1";
$query = $this->db->query($sql);

foreach($query->result() as $row)
{
    echo $row->picture_link;
}

Note, this code is generalized

General table code

echo "<table><tr>";
$count = 1;
foreach($query->result() as $row)
{
    if($count % 5 == 0)
    {
        echo "</tr><tr>";
    }

    echo "<td>" . $row->picture_link . "</td>";
    $count++;
}
Josh K
I know MySQL and SQL, it's just PHP am new too. This would just print them on 1 row each though? not along and down?
iamjonesy
Correct. What you're looking for is a table.
Josh K
thanks for adding in the extra code!Looks like it'll do what I want!
iamjonesy