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 CRUD Operations with PHP Creating Records Reading Data

I think I'm close...Code Challenge 2 of 2 for Reading Data from PHP CRUD

am i far off here? The error message I get says to remember to use single pairs of <ul> or <ol>. I've rearranged them several ways and I either get the same message or one that tells me challenge one is no longer passing.

index.php
<?php
function get_podcasts() {
    include 'connection.php';

    //add code here
  return $db->query('SELECT * FROM podcasts');
}
foreach (get_podcasts() as $item) {
  echo "<ul> <li>" . $item['title'] . " " . $item['podcast website'] . "</li> </ul>";
}

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Here's a couple of hints. Right now your code is making a separate <ul> for every item . This should be placed outside the loop and the loop should generate the list items <li>. Also, 'podcast' and 'website' are separate keys for that array, so you need to access them individually like you did the 'title'. Hope these hints help! :sparkles:

Brian DuPont
Brian DuPont
30,448 Points

As you have it, you are creating a new <ul> for each podcast. You need to echo out a <ul> before the foreach loop and a </ul> after, that way all the <li> items get into one <ul>

I got it! Thanks for the help! Much appreciated!