Jump to content

WHILE loop help


kapz22

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.