Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.