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';

         }
     }



?>
Member Avatar for LastMitch

@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) ?

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

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

Member Avatar for LastMitch

@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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.