无法显示关系表类别新闻

时间:2012-06-21 14:27:31

标签: php mysql

我试图回应一个与类别表相关的表中的数据,但我没有得到这个来显示数据,有些错误。

以下是一些代码:

tbl_category_news
- id_category_news
- 类别

tbl_news
- id_news
- id_category_news
-title
-description
-msg
-name_arquive
-legend

 <?php
     $categoryId = 1; 
      $sql_visualizar = mysql_query("SELECT * FROM tbl_news AS t1 JOIN tbl_category_news c
    ON c.id_category_news=t1.id_category_news WHERE id_category_news = {$categoryId}");
    while($linha = mysql_fetch_array($sql_visualizar)){
    $title = $linha ['title'];
    $description = $linha['description'];
    $msg = $linha['msg'];
    $legend = $linha['legend'];
    $nome_arquive = $linha['name_arquive'];
    $id_news = $linha['id_news'];

      ?>
<?php echo $msg?>
<?php
  }
  ?>

1 个答案:

答案 0 :(得分:0)

尝试替换WHERE id_category_news = {$categoryId} with WHERE t1.id_category_news = $categoryId