Welcome to the Treehouse Community
Looking to learn something new?
taha kazi1,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");
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
School name displayed only once (distinct won't work because each school name has 2-3 product credentials School A School B School C
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