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 trialMatt Schulze
6,311 PointsIn the PHP section "integrating PHP with DataBases, in the challenge "Working with Results", Im not sure how to do this.
The TIP is... we used this method in the previous video. I went back through the past 2 videos several times and cannot figure out how to extract the data from $results in order to pass them through the function.
<?php
include "helper.php";
try {
$results = $db->query(
"SELECT member_id, email, fullname, level FROM members"
);
} catch (Exception $e) {
echo $e->getMessage();
}
//add code below this line
$x = send_offer($results($member_id), $results($email), $results($fullname), $results($level));
2 Answers
Matt Schulze
6,311 PointsThank you for your help.
Instead of tossing me a fish, you taught me how to fish, even though I was about to sell the boat...lol
Joseph Yhu
PHP Development Techdegree Graduate 48,637 Points- You have to loop through the results.
- You have to use square brackets, not parentheses. Also, you have to use the column names instead of variables. E.g.:
$result['member_id']
not
$result($member_id)
Matt Schulze
6,311 PointsSquare brackets make sense, but I guess I don't understand the 'loop through the results' part.
Joseph Yhu
PHP Development Techdegree Graduate 48,637 Pointse.g.:
foreach ($results as $result) {
....
}