Jump to content

Query Condition


supaflyfrank

Recommended Posts

Is there a way to run a specific query depending on a value received during the query. For example.

I have two types of products. Regular and Packs. Regular is just a single item and packs are a group of different items. Now on my product listing page I want to display all my different types or products. My regular products will basically show image, mini description and price. On my packs I want to display image,mini description, price and a list of products that is included in the pack. But I want the list of products separate from the mini descriptions because its contents can be changed. So I am guessing in my table I need a way to determine if a product is regular or a pack. Therefore I basically have a True/False statement to determine if which type or product it is. The problem is I dont want to run an additional query trying to find all the items in a pack if the current product I am displaying isnt a pack. But at the same time when the query runs their is a chance that the product can be a pack. But this wont be determined until runtime. So I am wondering if their is any runtime query conditional statement that can run a single specific query depending on the product type as in

 

If producttype == "Regular"

  Get Price, MiniDescription and Images

elseif producttype == "Pack"

Get Price,MiniDescription and Images

 

Now I understand that it would be EXTREMELY easy if I just ran one query and then while displaying the item run another query but I wanted to avoid that if possible. So any suggestions would be great.

Link to comment
https://forums.phpfreaks.com/topic/66054-query-condition/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.