Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Amadeo DeSouza
Amadeo DeSouza
18,445 Points

A php challenge. Trying to apply shirts4mike to my project.

Long shot but here it goes!

I’m working on a site using what I’ve learned in the php track, and have run into a hurdle. Wondering if someone can help.

Short version, using shirts4mike site as an analogy:

I’m basically trying to get the shirt sizes that show up on the shirt details page to show up on the previous “All shirts” product page for each shirt. Forget the actual view (i.e. that its a dropdown) just trying to get the model code to work. Specifically the get_all_shirts(); function returns an array with shirt details. I want the last element in that array to be an array of the shirt sizes that are available.

I have a longer version of this question with my code, but as I was typing looked at it, but its very longs and a bit hard to understand, I can post but first wanted to see if anyone would even respond to the initial inquiry.

Thanks!

2 Answers

Amadeo DeSouza
Amadeo DeSouza
18,445 Points

Ok NEVERMIND I figured it out.

I kept trying to figure out how to add results generated by querying info for a single "shirt' to the array that had the info for all the shirts, all within the get_all_shirts function

HOWEVER, the answer was creating a new function to just get what I needed for an individual shirt and calling that function within the loop that echo's out each shirts info on the shirts.php page.

Chris Grazioli
Chris Grazioli
31,225 Points

Sund like you need to create a multidimensional array, with that last bit adding one more dimension. I would research array()

Amadeo DeSouza
Amadeo DeSouza
18,445 Points

Thanks Chris!

Yea I got that part, the trouble I was having was getting my results to add to the array. I'm trying something now that may work.

Thanks again!