水平显示Mysql表结果

时间:2015-03-22 17:50:30

标签: php mysql formatting

我试图弄清楚如何水平显示mysql表结果 http://lecs-viewer-web-components.s3.amazonaws.com/v3.0/agni/guide.html

实施例

name 1              name 2           name3
description     description       description
url                  url               url

这是我用作测试的代码

<?php
if (!$link = mysql_connect('', '', '')) {
    echo '700';
    exit;
}

if (!mysql_select_db('Radio', $link)) {
    echo '701';
    exit;
}

$items = 5;
  $query = "SELECT * FROM Stations";

 $result = mysql_query($query) or die(mysql_error());
 if (mysql_num_rows($result) > 0) {

 //echo '<table border="1">';
 while($row = mysql_fetch_array($result)){

 echo "<a href='index.php?date=" . $row[Name] . "' class='link'>$row[Name]</a>";   


}//end while loop
     echo "</tr>";
    echo '</table>';
}else{ echo 'no records found'; }



?>

我似乎无法按照我想要的方式显示数据,以使其看起来像上面的示例?

1 个答案:

答案 0 :(得分:0)

if (!$link = mysql_connect('', '', '')) {
    echo '700';
    exit;
}

if (!mysql_select_db('Radio', $link)) {
    echo '701';
    exit;
}

$items = 5;
$query = "SELECT * FROM Stations";

$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result) > 0) {

    echo '<table border="1">';
    echo '<tr>';
    while($row = mysql_fetch_array($result)){

        echo '<td>';
        echo '<div><a href="index.php?date=' . $row['Name'] . '" class="link">' . $row['Name'] . '</a></div>';
        echo '<div>' . $row['description'] . '</div>';
        echo '<div>' . $row['url'] . '</div>';
        echo '</td>';

    }//end while loop
    echo '</tr>';
    echo '</table>';

} else { echo 'no records found'; }