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 Integrating PHP with Databases Querying the Database with PHP Working with Results

Piyush Patel
Piyush Patel
17,253 Points

I don;t understand this question without full code.

Can someone help me with this?

I cannot understand this code without full code at my disposal.

2 Answers

Rodrigo Villalobos
Rodrigo Villalobos
2,546 Points

There is a send_offer function ready for you to use that accepts the following arguments: $member_id, $email, $fullname, $level.

This tells you that, at some point, you have to call the send_offer function, with the listed arguments like this:

send_offer( $member_id, $email, $fullname, $level )

The data from the database is currently in a PDOStatement object named $results. Loop through those results and pass them to the send_offer function.

This tells you that you have a available variable called $results, which you can loop through via a foreach, and inside the foreach, then call the send_offer function with all the parameters available in the row.

Piyush Patel
Piyush Patel
17,253 Points

Can't we fetch the data as

foreach($results as $id => $value) { $member_id = $item['member_id']; }

Is this right way?