Wrox Programmer Forums
|
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2010, 05:49 PM
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default I need help understanding the page 95 query.

On page 95 of the book there is some bolded code there that modifies the getSubCategories function in the MCats model. could someone please help me understand what exactly it's doing. The book gives no explanation of this code.

PHP Code:
foreach ($Q->result_array() as $row){
               
$sql "select thumbnail as src 
                       from products 
                       where category_id="
.id_clean($row['id'])."
                       and status='active'
                       order by rand() limit 1"
;
               
$Q2 $this->db->query($sql);
 
           
               if(
$Q2->num_rows() > 0){
                
$thumb $Q2->row_array();
                   
$THUMB $thumb['src'];
               }else{
                   
$THUMB '';
               }
               
$Q2->free_result();
               
$data[] = array(
                   
'id' => $row['id'], 
                   
'name' => $row['name'], 
                   
'shortdesc' => $row['shortdesc'],
                   
'thumbnail' => $THUMB
               
);
           } 
 
Old January 12th, 2011, 10:27 AM
Registered User
 
Join Date: Jan 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It selects a thumnail picture for your subcategory from one of the appropriate products picture. So you don't have an exact picture for all the subcategories, but the code randomly gets one for it.

Example: you have a computer webshop and you have subcategory "Webcams". If you click on Webcams subcat, it search through all webcam products and choose one's picture (for example a M* VX3000's) and puts for the subcategory, so you see visually too, that below this subcat are webcams..
Clear enough?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Page 95 Web Reference not working khaihon BOOK: Professional ASP.NET 3.5 SP1 Edition: In C# and VB 0 January 20th, 2010 07:21 PM
Chapter 3 Page 95 jumpot89 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 6 April 22nd, 2009 03:11 AM
Chapter 3 page 95 nead23 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 March 26th, 2009 09:28 AM
Chapter 3, page 95 Swerve1000 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 May 29th, 2007 04:45 PM
It wont Connect toMySQLChapter 3,Page 95-98, Alej PHP Databases 3 August 29th, 2006 11:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.