please help cant figure out why two pieces of code produce different results?

This is a discussion on please help cant figure out why two pieces of code produce different results? within the PHP forums, part of the Development category; Hi, i have some code PHP Code:      foreach ( $category_list  as  $category  =>  $sub_category )      {         switch( $category )         { ...


Reply
 
LinkBack Thread Tools Display Modes
Old 21st January 2010, 04:39 PM   #1
Member
 
ljackson's Avatar
 
Join Date: Feb 2009
Location: Cornwall
Posts: 372
Thanks: 22
Thanked 3 Times in 3 Posts
ljackson is on a distinguished road
Expertise: PHP
Experience: Intermediate
Exclamation please help cant figure out why two pieces of code produce different results?

Hi,

i have some code
PHP Code:
    foreach ($category_list as $category => $sub_category
    {
        switch(
$category)
        {
            case 
"DVD";
                
$aw_id "240";
                
$aw_name "DVDs";
                
$keywords "-region 1";
                break;
            case 
"CD";
                
$aw_id "241";
                
$aw_name "Music";
                
$keywords "";
                break;
            case 
"Video Games";
                
$aw_id "579";
                
$aw_name "Video Games";
                
$keywords "";
                break;
            case 
"Blu-Ray";
                
$aw_id "550";
                
$aw_name "Blu-Ray";
                
$keywords "-region 1";
                break;
            case 
"Books";
                
$aw_id "538";
                
$aw_name "Books";
                
$keywords "";
                break;
        }
        
        print 
"<div class='category_container'>";
        print 
"<h2 class='category_header red'>$category</h2>";
        print 
$keywords;
        
        
#GET TOP 5 ITEMS FOR EACH CATEGORY
        
$AW_catid $aw_id;
        
$AW_cat $aw_name;
        
$keywords "";
        
$oRefineBy = new stdClass();
        
$oRefineBy -> iId 4;
        
$oRefineBy -> sName 'Category';
        
$oRefineByDefinition = new stdClass();
        
$oRefineByDefinition -> sId $AW_catid;
        
$oRefineByDefinition -> sName $AW_cat;
        
$oRefineBy -> oRefineByDefinition $oRefineByDefinition;
        
$returnedcolumns = array(sName,sAwImageUrl,sMerchantImageUrl,sMerchantThumbUrl,sDescription,sBrand,iMerchantId,iCategoryId);        
        
$booleansearch = array("sQuery" => "$keywords""oActiveRefineByGroup" => $oRefineBy"bAdult" => true"iLimit"=>5"sColumnToReturn" => $returnedcolumns"bIncludeTree" => true"sSort"=>"popularity""sMode" => "boolean"); 
when defining the keywords "sQuery" => "$keywords" it returns different results from putting the keywords in the query instead of the varible name like so

PHP Code:
 $booleansearch = array("sQuery" => "-region 1""oActiveRefineByGroup" => $oRefineBy"bAdult" => true"iLimit"=>5"sColumnToReturn" => $returnedcolumns"bIncludeTree" => true"sSort"=>"popularity""sMode" => "boolean"); 
ive printed out the values of $keyword and they are correct but im not sure why im getting the two sets of results with what looks to be the same query?

also if i remove the quotes around $keywords i get the same results as i did with them?

any ideas?
thanks

Last edited by ljackson; 21st January 2010 at 04:49 PM..
ljackson is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!twitter
Reply With Quote
Reply

Tags
code, figure, pieces, produce, results

Thread Tools
Display Modes