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

taha kazi
taha kazi
1,376 Points

Use results from SQL as criteria to query another request via php

I am grabbing a list of school names from a database. When the user clicks on the school name, i want the code to fetch 2-3 other attributes related to the school name that the user has clicked on.

My code for the single school name list:

$query = mysql_query("Select schoolname, product, username, password from credentials c join products p on p.productid = c.productid join schools s on s.schoolid = c.schoolid join icons i on i.productid = p.productid order by s.schoolname");

echo '<ul>'; while($row = mysql_fetch_array($query)) {
echo "<li> <a href='#'>" . $row['schoolname'] . "</a> </li>"; } echo '</ul>';

Current Results: School A School A School B School B School B School C School C

Expected Results:

  1. School name displayed only once (distinct won't work because each school name has 2-3 product credentials School A School B School C

  2. Ability for User to click on a school and see product, username and password displayed (for example: user clicked on School A)

School A: product , username, password

School B School C

1 Answer

taha kazi
taha kazi
1,376 Points

anyone, help?