There is a query to the table

$result = mysql_query('SELECT * FROM `SS_products`', $conn); // запрос на выборку 

In the table there are 2 columns name and enabled, you need to display only those names, which enabled is not equal to 0. Tried so, does not show anything at all.

 while($row = mysql_fetch_array($result)) { if $row['enabled'] <>0 { echo $row['name'].'<br>' ;// выводим данные }} 

    2 answers 2

    It's easier to select the lines immediately where enabled=1

     $result = mysql_query('SELECT * FROM `SS_products` WHERE `enabled` <> 0;', $conn) 
    • Thank! The most optimal solution is sbaikov

    First you have an error in PHP code. The condition must be bracketed.

     while ($row = mysql_fetch_array($result)) { if ($row['enabled'] <> 0) { echo $row['name'] . '<br>'; // выводим данные } } 

    And secondly, it is better to filter the records by means of the DBMS itself.

     $result = mysql_query('SELECT * FROM `SS_products` WHERE `enabled` <> 0', $conn);