Show result of MYSQL select query in two div according to column name, using a single select query

I have a table with column names id,name,category,title,news. Once select query executes i get all the required data from table but i need to split up this data into two div according to the category they belong. there are two different categories, say A and B. I need to show all the data with a column category name A in one div and same with category B.

   $sql= "SELECT id, title ,news ,category FROM news  ";

    $query=mysql_query($sql, $ex)or die(mysql_error())  ;

    while($row=mysql_fetch_assoc($query)){ 

        $title=$row['title']; 

        if($row['category']=='  Latest News'){

            echo $row['title'];
        }

    }

My code doesn’t work. Any idea?


Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.