Support Forums

Extra Field Filter

This is a discussion on Extra Field Filter within the Modules / Plugins / Modifications forums, part of the Developer Forums category; Hi, Maybe someone can help with this: I'm trying to modify the plugin " function.feature_listings_vertical_home " adding it " products_fields ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 12-12-2009, 10:42 AM   #1
Customer
 
Join Date: Jun 2009
Posts: 127
Rep Power: 12
pipelin is on a distinguished road
Default Extra Field Filter

Hi,

Maybe someone can help with this:

I'm trying to modify the plugin "function.feature_listings_vertical_home" adding it "products_fields" table.

I need find the registers where fID==50 and sValue=='Toronto' then, find the featured in the listings table, but I got error (Query failed: Query was empty) and cant find it.

This is the code:

PHP Code:
$filter_field=(int)'50';
$fvalue 'Toronto';

$lsql 'SELECT pID, sValue, FROM ' .PREFIX'products_fields WHERE fID='.$filter_field.' ORDER BY fID ASC';
        
$fresult $db->query($sSQL);
        
$i=0;
        while (
$rs $fresult->fetch()) 
            {
                if (
$fvalue == $rs['sValue']) {

                    
$sSQL='SELECT id,title,price FROM '.PREFIX.'listings WHERE display = \'Y\' AND id = '.$rs['pID'].'  AND expiration > NOW() AND featured = \'Y\' ORDER BY '$sort .' LIMIT '.$number;
                    
$result=$db->query($sSQL);
                    
$row $result->fetch();
                    
                        
$imageSQL "SELECT image FROM ".PREFIX."prodimages WHERE pid=".$row['id']." ORDER BY rank LIMIT 1";
                        
$iResult=$db->query($imageSQL);
                        
$irs=$iResult->fetch();
                        if(
$irs['image']<>"")
                        {
                            
$image="thumbs/small_".$irs['image'];
                        }
                        else
                        {
                            
$image="http://www.68classifieds.com/forums/images/nophoto.gif";
                        }
                        
$tmp = array(
                            
'id' => $row['id'],
                            
'image'=> $image,
                            
'title'=> $row['title'],
                            
'price'=> FormatCurrency($row['price']),
                        );
                        
                } 
$loop[$i++] = $tmp
            } 
            
    
$loop_count count($loop)-1

Last edited by pipelin; 12-12-2009 at 11:14 AM.
pipelin is offline   Reply With Quote
Old 12-12-2009, 01:12 PM   #2
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,342
Rep Power: 84
seymourjames is a jewel in the rough
Default

Are you trying to do this generally. In other words, filter on an extrafield and display featured listings horizontally for that extrafield?
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates & Modules
Get the Best U.S Hosting, Best U.K Hosting
seymourjames is offline   Reply With Quote
Old 12-12-2009, 01:40 PM   #3
Customer
 
Join Date: Jun 2009
Posts: 127
Rep Power: 12
pipelin is on a distinguished road
Default

Yes, but in this case is verticall featured listing. I fixed some mistakes. this is the code

PHP Code:
    $lsql 'SELECT pID, sValue FROM ' .PREFIX'products_fields WHERE fID='.$filter_field.' ORDER BY fID ASC';
        
$fresult $db->query($lsql);
        
$i=0;
        while (
$rs $fresult->fetch()) 
            {
                if (
$fvalue == $rs['sValue']) {

                    
$sSQL='SELECT id,title,price FROM '.PREFIX.'listings WHERE display = \'Y\' AND id = '.$rs['pID'].'  AND expiration > NOW() AND featured = \'Y\' ORDER BY '$sort .' LIMIT '.$number;
                    
$result=$db->query($sSQL);
                    
$row $result->fetch();
                    
                        
$imageSQL "SELECT image FROM ".PREFIX."prodimages WHERE pid=".$row['id']." ORDER BY rank LIMIT 1";
                        
$iResult=$db->query($imageSQL);
                        
$irs=$iResult->fetch();
                        if(
$irs['image']<>"")
                        {
                            
$image="thumbs/small_".$irs['image'];
                        }
                        else
                        {
                            
$image="images/nophoto.gif";
                        }
                        
$tmp = array(
                            
'id' => $row['id'],
                            
'image'=> $image,
                            
'title'=> $row['title'],
                            
'price'=> FormatCurrency($row['price']),
                        );
                        
               
$loop[$i++] = $tmp;  } 
             } 
Now it is filtering the city correctly, BUT I got this error (Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY rank LIMIT 1' at line 1 SQL: SELECT image FROM class_textprodimages WHERE pid= ORDER BY rank LIMIT 1 in) for each register and after that it shows me the gallery, including all register for this city (featured and featured)
pipelin is offline   Reply With Quote
Old 12-12-2009, 01:51 PM   #4
Customer
 
Join Date: Jun 2009
Posts: 127
Rep Power: 12
pipelin is on a distinguished road
Default

I changed ".$row['id']." to pid=".$rs['pID']." in this line:

$imageSQL = "SELECT image FROM ".PREFIX."prodimages WHERE pid=".$row['id']." ORDER BY rank LIMIT 1";

new: $imageSQL = "SELECT image FROM ".PREFIX."prodimages WHERE pid=".$rs['pID']." ORDER BY rank LIMIT 1";

Now I dont get the errors it show me the gallery including all registers for that city

I think it is not taking this part of the if:

PHP Code:
 $sSQL='SELECT id,title,price FROM '.PREFIX.'listings WHERE display = \'Y\' AND id = '.$rs['pID'].'  AND expiration > NOW() AND featured = \'Y\' ORDER BY '$sort .' LIMIT '.$number;
                    
$result=$db->query($sSQL);
                    
$row $result->fetch(); 
I don't know why

Last edited by pipelin; 12-12-2009 at 01:57 PM.
pipelin is offline   Reply With Quote
Old 12-12-2009, 05:20 PM   #5
Customer
 
Join Date: Jun 2009
Posts: 127
Rep Power: 12
pipelin is on a distinguished road
Default

I fixed it. It was something weird with the featured field.

Thanks
pipelin is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a extra field just like the price field ? mirway7 Technical Support 3 10-12-2009 11:27 PM
Get Extra Field Eric Barnes Modification Release 4 11-28-2008 04:39 PM
Extra field kocicart Technical Support 8 08-25-2008 06:19 PM
Change format in "date field" extra field topbidz Technical Support 2 05-01-2008 07:38 PM


All times are GMT -4. The time now is 01:10 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0