嵌套子类别和父类别

时间:2014-02-17 12:37:47

标签: php mysql categories

<?php
mysql_select_db($database_dbconnect, $dbconnect);
$query_cats = "SELECT * FROM articles INNER JOIN categories ON articles.category_id =    categories.id GROUP BY articles.category_id ORDER BY articles.created DESC  LIMIT 0,    6";
$cats = mysql_query($query_cats, $dbconnect) or die(mysql_error());
$row_cats = mysql_fetch_assoc($cats);
$totalRows_cats = mysql_num_rows($cats);


?>

如何使用 php mysql 从每个类别中调用4篇文章。 请帮我处理数据库表和php编码,如下所示:

体育

  1. 网球文章
  2. 足球文章
  3. 拳击文章
  4. 娱乐

    1. 音乐文章
    2. 电影文章
    3. Celebs文章
    4. 我试试这段代码:

      <?php 
          do { 
              echo $row_cats['category_name']; 
              echo $row_cats['title']; 
      ?>
      </a></h3> 
      <?php 
      echo strip_tags(substr($row_cats['body'],0,100)); 
      ?>
              ... 
              <a href="article.php?id=<?php echo $row_cats['id']; ?>"> Full story </a> 
              <ul>
                <li><?php echo $row_cats['title']; ?>
                </li> 
              </ul>
      <?php 
          } while ($row_cats = mysql_fetch_assoc($cats)); 
      ?>
      

0 个答案:

没有答案