Current location: Hot Scripts Forums » Programming Languages » PHP » How to adjust number of columns generated by php classifieds script?


How to adjust number of columns generated by php classifieds script?

Reply
  #1 (permalink)  
Old 02-28-04, 02:40 PM
robertisunemployed robertisunemployed is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
How to adjust number of columns generated by php classifieds script?

Hi there,

I'm in the process of setting up a classifeds site and modifying a script I bought to suit my purposes.

Basically the script is only allowing 2 columns of catagories to be printed on the main page (leaving a large empty gap on most of the right hand side of the screen) when I need there to be three or more. Is there a simple way of changing the number of columns?

I've trawled through the above script, but like I said already, I am a bit of a novice so don't know exactly what to look for.

I hope someone can help....

Thanks again folks, it's down to very helpful individuals such as yourselves that I'm managing to get anything done at all!

Robert

PHP Code:

// generates the Yahoo style table with all first and second level categories with number of listings and number of new listings 

function generate_home_category_list($portal

    global 
$BBClass_verb
    
$now date("Y-m-d H:i:s"); 

    
$query "SELECT classifieds_categories.*, COUNT(classifieds_listings.listing_id) AS item_count FROM classifieds_categories LEFT JOIN classifieds_listings ON 
    ((classifieds_categories.category_id=SUBSTRING(classifieds_listings.category_id,1,2) OR classifieds_categories.category_id=SUBSTRING(classifieds_listings.category_id,1,4)) AND 
    classifieds_listings.status=20 AND classifieds_listings.exp_date >= '
$now') WHERE (classifieds_categories.display=1 AND (classifieds_categories.category_id LIKE '__' OR classifieds_categories.category_id LIKE '____')) 
    GROUP BY classifieds_categories.category_id ORDER BY classifieds_categories.category_name, classifieds_categories.category_id"


    
$this->db->query($query); 

    if (
$this->db->num_rows() > 0
    { 
        
$output '<table border="0" cellspacing="0" cellpadding="10" width="100%"><tr>' "\n"
        
// fetch the data 
        
while ($this->db->next_record()) 
        { 
            
$category_id $this->db->f('category_id'); 
            
$category_name $this->db->f('category_name'); 
            
$item_count $this->db->f('item_count'); 
            
$parent substr($category_id,0,2); 
            
$is_parent = (strlen($category_id) == 2) ? 0
            if (
$is_parent$parent_categories[$category_id] = array( "category_name" => $category_name"item_count" => $item_count); 
            else 
$child_categories[$parent][$category_id] = array( "category_name" => $category_name"item_count" => $item_count); 
        } 

        
// build the content 
        
$i=0
        
reset($parent_categories); 
        while(list(
$key$val) = each($parent_categories)) 
        { 
            
$output .= '<td align="left" valign="top" width="50%"><span class="cfmaincat"><b>' "\n"
            
$output .= '<a class="cfmaincat" href="'.$portal.'?cf_action=list&category_id='.$key.'">'.$val["category_name"].'</a>'
            if (
$val["item_count"] > || $this->show_zero_category_count) { 
            
$output .= '&nbsp;('.$val["item_count"].')'
            } 
            
$output .= '</b></span>'

            if (
$this->show_children_at_home
            { 
                
$output .= '<br /><span class="cfsubcat">' "\n"
                
$this_child $child_categories[$key]; 
                
reset($this_child); 
                
$j=0
                while(list(
$key$val) = each($this_child)) 
                { 
                    if (
$j 0$output .= ', '
                    
$output .= '<a class="cfsubcat" href="'.$portal.'?cf_action=list&category_id='.$key.'">' $val["category_name"] . '</a>'
                    if (
$val["item_count"] > 0$output .= '&nbsp;('.$val["item_count"].')'
                    
$j++; 
                } 
            } 
            
$output .= '</td>'
            if (
$i 2
            { 
                
$output .= '</tr><tr>' "\n"
                
$add_td false
            } else 
$add_td true
            
$i++; 
        } 
        if (
$add_td$output .= "<td>&nbsp;</td>"
        
$output .= '</tr></table>'

    } else 
$output '<p class="bbclasserror">There are no categories defined yet.</p>'
    return 
$output

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
Need a good PHP classifieds script.. neworleans rookie Script Requests 3 04-29-04 10:49 PM
Please help me sort out a small part of my php script... robertisunemployed PHP 8 03-03-04 10:02 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
Affiliate script (PHP) whtiebear Job Offers & Assistance 2 12-21-03 12:12 AM


All times are GMT -5. The time now is 09:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.