[Solved] If value is true show, if value is false show something else


Your statement here is not correct:

<?php
    $category_id = ('category_id' == 3);
?>

You are trying to compare a string with an integer and this always returns false.

Edit:

After you execute your query, you need to fetch the data from the database. After you have stored the data in a variable (e.g. $data), you can compare it like this:

<?php
  $category_id = ((int)$data['category_id'] == 3);
?>

Edit: @cwd:

Here is one way to do it:

<?php
  //$con is database connection object
  $result = mysqli_query($con,"SELECT `logo_id`, `creation`, `logo_name`, `category_id`, `org_img`, `new_img` FROM `logos` WHERE category_id = 3 ORDER BY `logo_id` DESC LIMIT 0,1");
  $row = mysqli_fetch_assoc($result);
  $category_id = (int)$row['category_id'] == 3 ?true:false;
 ?>

This might help you.

1

solved If value is true show, if value is false show something else