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

Please tell me the answer of Challenge Task 1 of 1 of Integrating PHP with Database.

Please tell me the answer of Challenge Task 1 of 1 of Integrating PHP with Database.

index.php
<?php
include "helper.php";

try {
    $results = $db->query(
        "SELECT member_id, email, fullname, level FROM members"
    );
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}
//add code below this line
$send_offer=$results->fetchAll();

2 Answers

Hi. Thank you very much. I really appreciate it.

Glad I was able to help you Kohane. I would appreciate you selecting my answer as best answer so others will be pointed to the best help. Thanks.

Hello Kohane Kagami

I hope you are asking for the answer so you can see what you did wrong. Based on what you provided, I would say you need read instructions better or to go back to PHP basics course.

You had:

<?php
$send_offer=$results->fetchAll();

Issues

  • In instructions it states send_offer is a function, you are assigning $send_offer variable and not calling like a function.
  • There was no attempt to loop over the results.
  • There was no attempt to take column values and pass into function parameters

Why go through course if you are not invested in learning?

Correct Answer

<?php
$members = $results->fetchAll();
foreach($members as $member){
  send_offer($member['member_id'],$member['email'],$member['fullname'],$member['level']);
}