Group mysql results by category and display them into groups under each category

后端 未结 4 808
别跟我提以往
别跟我提以往 2020-12-07 02:27

I am trying to create a simple css menu that gets the data from a mysql table.

My idea is to have menu like this

    Category 1
    - link 1
    - li         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 02:57

    Your query is wrong

    $sql = "SELECT * FROM content WHERE group by category";
    

    should be

    $sql = "SELECT * FROM content group by category";
    

    Also since mysql is deprecated avoid using it. Use mysqli or PDO instead

提交回复
热议问题