开发者

How to make a result like following

开发者 https://www.devze.com 2023-03-15 22:18 出处:网络
I wanna create a db result as follows: <div class=\"entries\"> <div class=\"page\"> <a href=\"KimAronson-TwentySeconds59483.m4v\" class=\"first\"> Palm trees and a hot sun <br /&

I wanna create a db result as follows:

<div class="entries">
  <div class="page"> <a href="KimAronson-TwentySeconds59483.m4v" class="first"> Palm trees and a hot sun <br />
    <em>0:20 min</em> </a> <a href="KimAronson-TwentySeconds58192.m4v"> Playing around with toes <br />
    <em>0:20 min</em> </a> <a href="KimAronson-TwentySeconds63617.m4v"> Small lake and a bicycle <br />
    <em>0:20 min</em> </a> <a href="KimAronson-TwentySeconds64268.m4v"> Hotel Room 213 In San Fransisco <br />
    <em>0:20 min</em> </a> </div>
  <div class="page"> <a href="KimAronson-TwentySeconds67463.m4v"> Some Hebrew letters on a paper<br />
    <em>0:20 min</em> </a> <a href="KimAronson-TwentySeconds65459.m4v"> Driving Golden gate bridge <br />
    <em>0:21 min</em> </a> <a href="KimAronson-TwentySeconds70930.m4v"> Eating Sushi and being trendy <br />
    <em>0:21 min</em> </a> <a href="KimAronson-TwentySeconds72119.m4v"> Big spider web on home garden <br />
    <em>0:23 min</em> </a> </div>
  <div class="page"> <a href="KimAronson-TwentySeconds71844.m4v"> Random Miniature Characters <br />
    <em>0:21 min</em> </a> <a href="KimAronson-TwentySeconds73213.m4v"> Things on the table and hidden camera <br />
    <em>0:21 min</em> </a> <a href="KimAronson-TwentySeconds75235.m4v"> Two little girls hand in hand <br />
    <em>0:21 min</em> </a> <a href="KimAronson-TwentySeconds67463.m4v"> Hebrew writings on paper again<br />
    <em>0:20 min</em> </a> </div>
</div>

can anybody tell me how can I do it with following query

$sql = "SELECT id, video_name, video_file_name, thumbnail_image, is_default FROM videos ORDER BY is_default DESC";
            $result = mysql_query($sql);
            $num = mysql_num_rows($result);
            $per_div = ceil($num/4);
            //echo "Per Div " . $per_div;
            while($row = mysql_fetch_array($result)){
                echo '<div class="page">';
                    while($row1 = mysql_fetch_array($result)){
                        echo '<a href="KimAronson-Twenty开发者_运维技巧Seconds59483.m4v"> Palm trees and a hot sun <br />
    <em>0:20 min</em> </a>';    
                    }
                echo '</div>';  
            }

Thanks


EDIT: Assuming that you want the results in groups of four:

$sql = "SELECT id, video_name, video_file_name, thumbnail_image, is_default FROM videos ORDER BY is_default DESC";
$result = mysql_query($sql);
$out = array('<div class="page">');
$i = 0;
while($row = mysql_fetch_array($result)){
    $out[] = '<a href="' . htmlspecialchars($row['video_file_name']) . '"> ' . htmlspecialchars($row['video_name']) . ' <br /><em>?:?? min</em> </a>';
    if ($i % 4 === 0) {
        $out[] = '</div>';
        $out[] = '<div class="page">';
    }
    $i++;
}
$out[] = '</div>';
print implode("\n", $out);

(untested)


You may need to try this

foreach ($result as $row) {
echo "<a href=".$row['video_file_path']."> ". $row['video_name']."</a>"
}
0

精彩评论

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

关注公众号