0

Hi,

I really have no idea why my if statement is showing no products when the quantity of my products is not 0, if it is then it will show no products, but the quantity of the products is more than 0. Also, there are jsut two items stored in the database. I have connected to the database and I'm sure nothing is wrong with that.

  <?php

      session_start();

      $page = 'index.php'; 


     mysqli_connect("host", "username", "******", "database"); 


     function products () {

       $get = mysqli_query('SELECT ID,Name,Description,Price FROM Products WHERE ID  > 0 ORDER BY ID DESC ');  

       if (mysqli_num_rows($get) == 0) {

           echo 'no products';           
       }
         else {

             echo 'success';

         }
     }



?>
2
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by LastMitch
2

@KRUX17

I really have no idea why my if statement is showing no products when the quantity of my products is not 0, if it is then it will show no products, but the quantity of the products is more than 0. Also, there are jsut two items stored in the database. I have connected to the database and I'm sure nothing is wrong with that.

Can you provide a little more code?

Where is this:

mysqli_fetch_assoc($get) ?
0

Oh, I haven't used the mysqli_fetch_assoc. What does this function extactly do?

Edited by KRUX17

0

Where do I excatly put the mysqli_fetch_assoc($get)?

2

@KRUX17

Oh, I haven't used the mysqli_fetch_assoc. What does this function extactly do?

I read your old threads, this is your first time posting in the PHP section?

So base on your answer you don't know much about PHP.

Are you connected to the database? If not

Read this

http://www.daniweb.com/web-development/php/code/434480/using-phpmysqli-with-error-checking

This function is to get the data from the query.

mysqli_fetch_assoc($get)

since you don't understand it and plus this code is more related to products.

My suggestion is to read up more about this

http://php.net/manual/en/mysqli-result.fetch-assoc.php

Edited by LastMitch: grammer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.