kapz22 Posted March 21, 2010 Share Posted March 21, 2010 hi all, I am in need of urgent assistance. situation: I am building a web application where customers are able to rent out dvds. I am doing a While loop to retrieve the name of the dvd's and the results are displayed in a table. If a member rents out a dvd, the information goes into another table (memberToDVD) contain the member Id and a dvd id to see which member has whcih dvd. Issue I am doing a while loop to echo out the dvd name from the dvd table. Within this while loop, i need to somehow, for each dvd echo out a simple line stating if that dvd is being rented by customer. I am using the code below. $sqlSelectDVD = "SELECT * FROM dvd"; $resultSelectDVD = mysql_query($sqlSelectDVD); $sqlMemberRentlist = "SELECT * FROM rent LEFT JOIN dvd ON dvd.dvdId = rent.dvdId WHERE rent.memberId='1'; $resultMemberRentlist = mysql_query($sqlMemberRentlist); while ($rowGetDVD = mysql_fetch_assoc($resultSelectDVD)) { echo "DVD Indormation: "$rowGetDVD["dvdId"] . " - " . $rowGetDVD["name"] . "<br />"; while ($rowGetMemberRentlist = mysql_fetch_assoc($resultMemberRentlist)) { if($rowGetMemberRentlist["dvdId"] == $rowGetDVD["dvdId"]){ echo "You have this DVD on rent"; } } } I just dont know what to do. Can someone please help me. i have spent 2 days on this issue and just do now know what to do. Link to comment https://forums.phpfreaks.com/topic/196025-while-loop-help/ Share on other sites More sharing options...
devofash Posted March 21, 2010 Share Posted March 21, 2010 Look into JOINs http://www.w3schools.com/sql/sql_join.asp Link to comment https://forums.phpfreaks.com/topic/196025-while-loop-help/#findComment-1029648 Share on other sites More sharing options...
coupe-r Posted March 21, 2010 Share Posted March 21, 2010 What is being echoed and what "should" be echoed? Link to comment https://forums.phpfreaks.com/topic/196025-while-loop-help/#findComment-1029671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.