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

Cant Solve This

I think I have done can ever do, what is the solution for this? and where am I doing wrong?

$send_offer = $results -> query("SELECT member_id, email, fullname, level FROM members"); $send_offer ->fetchAll();

index.php
<?php
include "helper.php";
$send_offer = $results -> query("SELECT member_id, email, fullname, level FROM members");
$send_offer ->fetchAll();
/* 
 * helper.php contains
 * $results->query("SELECT member_id, email, fullname, level FROM members");
 */

2 Answers

Heja.. i think you have misunderstood this question. You just need to loop over the given results array and pass each value to the send_offer function. No need for SQL Statements here.

<?php
include "helper.php";

foreach($results as $result) {
  send_offer($result['member_id'], $result['email'], $result['fullname'], $result['level']);
}
/* 
 * helper.php contains
 * $results->query("SELECT member_id, email, fullname, level FROM members");
 */

aww bummer, thank you man:)