在viewpost.php上获取错误任何一个帮助我

时间:2014-09-09 09:36:46

标签: php mysql

<?php
    $reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages;
    echo '<div class="pagination"><ul>';
    if ($total_pages > 1) {
        echo paginate($reload, $show_page, $total_pages);
    }
    echo "</ul></div>";
    // display data in table

    echo "<table class='imagetable'>";
    echo "<thead><tr><th>Title</th> <th>Last Date</th><th>View Details</th></tr></thead>";
    // loop through results of database query, displaying them in the table 
    for ($i = $start; $i < $end; $i++) {
        // make sure that PHP doesn't try to show results that don't exist
        if ($i == $total_results) {
            break;
        }

        // echo out the contents of each row into a table
        echo '<td>' . mysql_result($result, $i, 'title') . '</td>';
        echo '<td>' . mysql_result($result, $i, 'date') . '</td>';
      echo '<td><a href="' . mysql_result($result, $i, "viewpost.php"?id=<?php echo '$row[0]'?>) . '"></td>';
        echo "</tr>";
    }       
    // close table>
echo "</table>";
// pagination
?>

在viewpost.php上获取错误任何人都可以帮助我。

3 个答案:

答案 0 :(得分:2)

以下行中有错误。变化

echo '<td><a href="' . mysql_result($result, $i, "viewpost.php"?id=<?php echo '$row[0]'?>) . '"></td>';
                                                              ^

echo '<td><a href="' . mysql_result($result, $i, "viewpost.php?id=$row[0]") . '"></td>';
                                                                  ^

不要像在此行中那样将PHP括在单引号内。此外,URL参数也应该用双引号括起来,因为它也是字符串。当您使用echo时,您不需要在同一行中再次指定PHP标记。

答案 1 :(得分:0)

我不知道它是什么意思

mysql_result($result, $i, "viewpost.php"?id=<?php echo '$row[0]'?>)

mysql_result($result, $i, "columnname")."?id=".$row[0]);

尝试#2

$pageId=mysql_result($result, $i, 'id');
echo '<td><a href="test.php?id='.$pageId.'"></td>';

答案 2 :(得分:0)

  echo '<td><a href="' . mysql_result($result, $i, "viewpost.php"?id=<?php echo '$row[0]'?>) . '"></td>';

我认为以viewpost.php开头的字符串需要转换为字符串。目前你已经看到了一些剪切和粘贴的内联PHP代码,你想要的是一个字符串。这里有PHP的close标签,不起作用。

您打算将什么传递给mysql_result函数? <?php echo '$row[0]'?>应该做什么?