Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Query help please...

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-27-2009, 04:08 AM
 
mrerotic mrerotic is offline
 

eXpert
  
Join Date: Feb 2009
Posts: 264
 

Default Query help please...

How can I check to see if parentid = '1' for a product? I think my query below is wrong can someone please verify that this query should work?
PHP Code:
$test func_query("SELECT productid FROM $sql_tbl[products] WHERE product = '$p[product]'");
// Get category parentid to find section for product
$pcatquery "SELECT categoryid FROM $sql_tbl[products_categories] WHERE productid = '".$test."'";
$prodcatinfo func_query($pcatquery);
 
if (!empty(
$prodcatinfo)){
foreach (
$prodcatinfo as $pcat){
$getpquery func_query("SELECT parentid, category FROM $sql_tbl[categories] WHERE categoryid = '".$pcat['categoryid']."'");
foreach (
$getpquery as $getpcat){
if (
$getpcat['parentid'] != '0'){
if (
$getpcat['parentid'] == '1'){
$pcatsection "dvds";
}
}
}
}

__________________
x-cart 4.2.3
AlteredCart Smart Search
Auto Featured Products Mod (Personal Mod)
BCSE Product Importer Pro & Drop Shipper Pro
CDSEO Pro
CMS EZRecommends
EE slider login (Personal Mod)
Next Prev Link Mod (Customized)
ShadowBox Detailed Images (Personal Mod)
Shop By Price (Customized)
Social Media (Personal Mod)
Switch Layout View (Personal Mod)
Special Offers
Testimonials (Personal Mod)
Whats New (Customized)
Reply With Quote
  #2  
Old 10-27-2009, 05:56 AM
  rogue's Avatar 
rogue rogue is offline
 

X-Adept
  
Join Date: Apr 2007
Location: Loveland, Ohio
Posts: 770
 

Default Re: Query help please...

I suspect that you need more than you are asking for here. But here is a single query that will do what you want I think.

Code:
$result = func_query(" SELECT cats.parentid FROM $sql_tbl[products] as prods, $sql_tbl[products_categories] as prod_cats, $sql_tbl[categories] as cats WHERE prods.product = '$p[product]' and cats.productid = prods.productid and prod_cats.categoryid = cats.categoryid and prod_cats.parentid = 1 ") if (count($result) == 1) { $pcatsection = 'dvds'; }

You should probably run the query from phpMyAdmin to make sure it does what you want.

Rick
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:19 AM.

   

 
X-Cart forums © 2001-2020