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

Timo Bontenbal
Timo Bontenbal
9,582 Points

PHP get data from two tables.

Hi,

I have two tables in my database Joukkueet and pisteet. But now i need to echo out the team name and how many points they have. Each team can have multiple points.

I would like to echo them side by side (image1)

image1 Can't upload images to post here's the link to the image

Here is my database structure.

Jouukkueet tabble(image2)

image2 Can't upload images to post here's the link to the image

Pisteet tabble(image3)

image3 Can't upload images to post here's the link to the image

The tables are relational tables the Joukkueet table id is the same as Pisteet tables team_id

From the Joukkueet table i need to get the name row and From Pisteet table i need to get Pistee_1 and Pisteet_2

How can i loop through the tables with php and get the Team name and then underneath of that print the points?

I am using PDO.

1 Answer