Jump to content

I am not sure about this a loop will work as the intended display.


co.ador

Recommended Posts

The while loop or php code below the query is coded is intended to produce the same display I have illustrated below the php code wrapped in code tags. I come here because I am not sure if the php code will exactly produce the same display that you guys can see in the INTENDED DISPLAY illustration i have done below.

$result = mysql_query("SELECT
                      cart.id         cart_id,
                      cart.id         cart_id,
                      cart.cartId     cartId,
                      cart.cookieId   cookie_Id,
                      cart.qty        qt_y,                     
                      cdkb.id         cdkb_id,
                      cdkb.name       name,
                      cdkb.image      image,
                      cdkb.price      price,
                      dkb.id          dkb_id,
                      dkb.name        name1, 
                      dkb.image       image1,
                      dkb.price       price2,
                      dbl.product_id  product_id,
    		      dbl.price       price3,
    		      dbl.variety     variety,
    		      dbl.description description                  
    FROM
            cart
        
    
            LEFT OUTER JOIN cdkb
               ON cart.id = cdkb.id    
          
            LEFT OUTER JOIN dkb
               ON cart.id = dkb.id
                    
            LEFT OUTER JOIN dbl
               ON dbl.id = dkb.id 
        
              
        WHERE
            cart.cookieId ='" . GetCartId() . "' ' ORDER BY cdkb.name AND dkb.name ASC"); 
     while($row = mysql_fetch_array($result))
    {  if($row['cdkb_id']){
    echo "<div>qty</div>";
    echo"<div>". $row['image'] . "</div>";
    echo"<div>". $row['name'] . "</div>";
    echo"<div>". $row['price'] . "</div>";
    echo"<div>remove</div>";
    }
    else{
    echo "<div>qty</div>";
    echo"<div>". $row['image1'] . "</div>";
    echo"<div>". $row['name1'] . "</div>";
    foreach ($row['dkb_id'] as $variety) {
    echo"<div>".$variety['variety']. $variety['price3'] . "</div>";
    // the vriety and price3 field will display three times as in table dbl has three prices and three variety. It is correct to use a foreach loop for  in this case?}
    echo"<div>remove</div>"; 
    // end of foreach loop inside the else statement
    }// end of if else statement
    }// end of while loop
    ?>
    

 

So the final display or INTENDED DISPLAY illustration is as below but i am not sure if the code above will exactly produce as below.

 

   

 while($row = mysql_fetch_array($result))
    {  
    if (table cdkb) { 
      [1]qyt         image      name          price        remove
         1            ---       marina        $18.90        remove?    
         }end of if statement
    Else table dkb {
       1]qyt            Image         Name             Price                  Remove
         1               ---         marina         Small Tray  $18.90        remove? 
                                                    Medium Tray $30.24
                                                    Large Tray  $35.90
                      } // end of else statement
                      
                      }//end of while loop

 

 

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.