功能不打印出链接

时间:2015-08-22 18:41:25

标签: php mysql

希望有人可以发现我的错误,但链接没有打印出来。

功能:

function getGames($console) {
    $query = 'SELECT * FROM `games` WHERE `console` = ? ORDER BY `name` ASC';
    $params = array($console);
    $results = dataQuery($query,$params);
    foreach ($results as $result) {
        echo '<td style="float: left;padding-left: 5px;>';
        echo '<a href="?page=ladders/game&id='.$result['id'].'" title="'.$result['name'].'">';
        echo '<img src="images/games/'.$result['image'].'" alt="'.$result['name'].'" width="100px" height="100px" />';
        echo '</a>';
        echo '</td>';
    }
}

它打印出的图像很好但不可点击,这意味着<a href部分出现了某种混乱。不过,这对我来说是正确的。

1 个答案:

答案 0 :(得分:1)

<td style="float: left;padding-left: 5px;>

缺少双引号
function getGames($console) {
    $query = 'SELECT * FROM `games` WHERE `console` = ? ORDER BY `name` ASC';
    $params = array($console);
    $results = dataQuery($query,$params);
    foreach ($results as $result) {
        echo '<td style="float: left;padding-left: 5px;">';
        echo '<a href="?page=ladders/game&id='.$result['id'].'" title="'.$result['name'].'">';
        echo '<img src="images/games/'.$result['image'].'" alt="'.$result['name'].'" width="100px" height="100px" />';
        echo '</a>';
        echo '</td>';
    }
}