表数据行显示0而不是来自mysql的数据?

时间:2014-07-23 10:32:50

标签: php html mysql

我的部分代码存在问题,我必须将数据从变量显示到表数据中。我试图调试这个问题,但我仍然不知道那个问题在哪里。表数据显示0.非常感谢。

PHP:

if($where == "Article"){
$sql2 = "SELECT * FROM ats_Articles WHERE art_ID = $what";
// 2293 result of echo $what;
$result2 = mysql_query($sql2) or die(mysql_error());
$sql_art_id = "";
$sql_art_title = "";
$sql_cat_id = "";
$sql_cat_title = "";
    while($row2 = mysql_fetch_assoc($result2)){
        $sql_art_id = $row2['art_ID'];
        $sql_cat_id = $row2['art_CategoryID'];
        // 12 result of echo $sql_cat_id ;
        $sql_art_title = friendly_url($row2['art_Title']);
    }
    $sql3 = "SELECT * FROM ats_Categories WHERE cat_ID = $sql_cat_id";
    // 12 echo $sql_cat_id;
    $result3 = mysql_query($sql3) or die(mysql_error());
    while($row3 = mysql_fetch_assoc($result3)){
        $sql_cat_title = friendly_url($row3['cat_Name_en']);
        // testacc result of echo $user
        // 2014-07-22 13:03:46 result of echo $date
        // 2293 result of echo $what
        // Article result of $where
        // testimonials result of echo $sql_cat_title;
        echo "<td> $user </td><td> $date </td><td><a href='http://example.com/gb/en/$sql_cat_id"+"_$sql_cat_title/$sql_art_id"+"_$sql_art_title.html'> $what </a></td><td> $where </td>";
        // above echo is 0 why ?
    }

}

1 个答案:

答案 0 :(得分:0)

使用连接运算符"." (dot)代替加号(+)

echo "<td> $user </td><td> $date </td><td><a href='http://example.com/gb/en/$sql_cat_id" . "_$sql_cat_title/$sql_art_id" . "_$sql_art_title.html'> $what </a></td><td> $where </td>";