开发者

How to structure outputed data in specific table order

开发者 https://www.devze.com 2023-01-13 19:39 出处:网络
How would you display / Echo pictures with a name underneeth in the order shown on the example below in php ? Sort of like echoing a friends list. Im looking for how to structure it with code, I guess

How would you display / Echo pictures with a name underneeth in the order shown on the example below in php ? Sort of like echoing a friends list. Im looking for how to structure it with code, I guess thats the correct way to explain what I want to achieve, hope that helps.

I tried

echo '
    <tr>
        <td align=\"center\">
            <img src=\"hello.png\" alt=\"My Picture\" /><br /> Name
        </td>
    </tr>
    ';

but that still does not quite work

What i want to acheive,

How to structure outputed data in specific table order

Sorry for the bad explanation, any help and examples would be he开发者_如何学Golpful

Thanks!


You need to count how many images you've echoed in your loop, if it's 4 images, echo a </tr><tr>

$td_count = 0;
$len = 50;

echo '<table border="1"><tr>';

while ($td_count <= $len)
{
  if (!($td_count % 4)) echo '</tr><tr>';

  echo '<td align=\"center\">cell '.$td_count.'</td>';

  $td_count++;

}
echo '</tr></table>'
0

精彩评论

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