开发者

Filling out a table horizontal and vertically with php and mysql

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 an开发者_如何转开发d 4 down. How would I do this?


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++;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜