0

geeting a error
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\E_COMMERCE\MENU_PAGES\apparel_pages\male_print_image.php on line 35

line 35: while($row = mysql_fetch_assoc($item_query))

<?php
...
     if(isset($_POST['male_button'])) 
       {
          $order_by_p  = $_POST['order_by'];             
          if($order_by_p == 'heigh_low')
           {
            $item_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' ORDER BY id DESC LIMIT 8"); 
            }                
         }
         else
        {
           $item_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' LIMIT 8"); 
        }

                    while($row = mysql_fetch_assoc($item_query))
                    {
                    .....

===============

form page

<form action='male_print_image.php' method='POST'>
              <label>Sub Category:</label> 
               <select  name="order_by">
                 <option value="">Choose...</option>
                   <option value="most_popular">Most Popular</option>
                  <option value="title">Title</option>
                 <option value="newest">Newest</option>
                  <option value="oldest">Oldest</option>
                  <option value="low_heigh">Price: Low to Heigh</option>
                  <option value="heigh_low">Price: Height to Low</option>
                </select>

              <div id="submit">
                        <button type="submit" id="male_button" class="button" name="male_button">go</button>
              </div> 
            </form>

Edited by hwoarang69

3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by diafol
Featured Replies
  • 1

    That would mean the query failed. It looks correct at first glance, so are you sure you are connected correctly? I suggest you add some error checking to find out. Read More

  • 1

    Are you sure there is an `id` column in the `item` table? Do this: $item_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' ORDER BY id DESC LIMIT 8") or die(mysql_error()); Read More

  • 1
    diafol 3,303   4 Years Ago

    From where I'm looking, this table looks a bit awkward. I'd make the sub_category field an **integer** related to a subcategories table. Read More

1

That would mean the query failed. It looks correct at first glance, so are you sure you are connected correctly? I suggest you add some error checking to find out.

0

yes iam connect to database. i just puted some error. and this one is not working:

 $item_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' ORDER BY id DESC LIMIT 8");

but this query works fine:

$item_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' LIMIT 8");

also note if i switch two query than the 2nd one will work. for some resone the one in if statment doesnt work.

Edited by Dani: Fixed formatting

1

Are you sure there is an id column in the item table?

Do this:

$item_query = mysql_query("SELECT * FROM item WHERE sub_category='Male_T-Shirts' ORDER BY id DESC LIMIT 8") or die(mysql_error());
1

From where I'm looking, this table looks a bit awkward. I'd make the sub_category field an integer related to a subcategories table.

This question has already been answered. 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.