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 July 15th, 2010, 04:46 PM
Registered User
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with getRandomProducts Function

Hi, I'm having a problem with the getRandomProducts function in that I can only get one product to display even though the products table has four items in it, including the Main Feature (which works fine).

I've tried to troubleshoot this and did a print_r to a test view and got the following printout (see below). As you can see below, the result_array shows the entire array (three records) as I would expect, but only the last record (record 4, Men's Pants) displays.

The foreach loop in the getRandomProducts function should add the results of the query of the products table into the $temp array. The rest should randomize the results and put them in the right-hand column via the home.php view (at least that's my understanding of how the process works). What I don't understand is how the data are available in the result_array function but fails to display when it's transferred to the view. Below is the result of my print_r printout. Please not that array elements 0, 1, and 2 appear, but the bottom shows only 2. Why???

(
[Q] => CI_DB_mysql_result Object
(
[conn_id] => Resource id #34
[result_id] => Resource id #46
[result_array] => Array
(
[0] => Array
(
[id] => 2
[name] => Shoes 1
[thumbnail] => images/american_flag3.jpg
[category_id] => 2
)

[1] => Array
(
[id] => 3
[name] => Men's Shoes
[thumbnail] => images/american_flag3.jpg
[category_id] => 2
)

[2] => Array
(
[id] => 4
[name] => Men's Pants
[thumbnail] => images/american_flag3.jpg
[category_id] => 2
)

)

[result_object] => Array
(
)

[current_row] => 0
[num_rows] => 3
[row_data] =>
)

[bool] => true
[2] => Array
(
[id] => 4
[name] => Men's Pants
[thumbnail] => images/american_flag3.jpg
)

)





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem function lejka Java Basics 1 August 20th, 2009 02:53 AM
function problem lejka Java Basics 0 August 7th, 2009 02:31 AM
Problem with Round Function darrenb Access 3 May 22nd, 2007 05:45 PM
Problem with function mat41 Classic ASP Basics 3 July 16th, 2005 01:19 AM
shell function problem bml Excel VBA 1 February 12th, 2005 05:42 PM





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