php - Query search # going up in ascending order rather then fetching the actual code from database


I have a query fetching product ID from the database, then base on the ID #, I have a switch statement that gets the image for the product. All works fine and at the end of the switch I have a default case where it would just print out an image that says "no image available".

Here is part of the code for imagequery.php

if($image = mysqli_fetch_assoc($imagequery))
case 0:
  echo '<th><img src="Images/pencil.jpg">';
case 1:
  echo '<th><img src="Images/pen.jpg">';
case 2:
  echo '<th><img src="Images/marker.png">';
case 3:
  echo '<th><img src="Images/clipper.png">';
case 4:
  echo '<th><img src="Images/paper.png">';
  echo '<th><img src="Images/noimage.jpg">';

Edit1: After doing more recommended echo checks, turns out the $image['imagequery'] is going in ascending order and I'm not sure why. My code to get $imagequery is this.

    $results = "SELECT product_code FROM products WHERE product_desc='Office Materials'";
    $imagequery = mysqli_query($mysqli, $results);

People are also looking for solutions to the problem: php - #laravel 419 error appear submission of any form this problem only on GoDaddy hosting on other hosting app works fine


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.