SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    May 2003
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why is the generated html code SO different ?

    Hi,

    I cannot work out why the generated html code is so different as follows:

    1. Main calling PHP file - product_info.php

    PHP Code:
             if ( (USE_CACHE == 'true') && !defined('SID')) {
               echo 
    tep_cache_also_purchased(3600);
             } else {
               include(
    DIR_WS_MODULES FILENAME_ALSO_PURCHASED_PRODUCTS);
             }
           }
         
    ?>
                     </form>
                   </td>
                 </tr>
               </table>
             </td>
         <!-- body_text_eof //--> 
    2. All of the included file - also_purchased_products.php

    PHP Code:
         <?php
         
           
    if (isset($HTTP_GET_VARS['products_id'])) {
         
    $orders_query tep_db_query("select p.products_id, p.products_image from " TABLE_ORDERS_PRODUCTS " opa, " TABLE_ORDERS_PRODUCTS " opb, " TABLE_ORDERS " o, " TABLE_PRODUCTS " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " MAX_DISPLAY_ALSO_PURCHASED);
             
    $num_products_ordered tep_db_num_rows($orders_query);
             if (
    $num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED) {
         
    ?>
         <!-- also_purchased_products //-->
         <?php
               $info_box_contents 
    = array();
               
    $info_box_contents[] = array('text' => TEXT_ALSO_PURCHASED_PRODUCTS);
         
               new 
    contentBoxHeading($info_box_contents);
         
               
    $row 0;
               
    $col 0;
               
    $info_box_contents = array();
               while (
    $orders tep_db_fetch_array($orders_query)) {
                 
    $orders['products_name'] = tep_get_products_name($orders['products_id']);
                 
    $info_box_contents[$row][$col] = array('align' => 'center',
                                                  
    'params' => 'class="smallText" width="33%" valign="top"',
                                                  
    'text' => '<a href="' tep_href_link(FILENAME_PRODUCT_INFO'products_id=' $orders['products_id']) . '">' tep_image(DIR_WS_IMAGES $orders['products_image'], $orders['products_name'], SMALL_IMAGE_WIDTHSMALL_IMAGE_HEIGHT) . '</a><br><a href="' tep_href_link(FILENAME_PRODUCT_INFO'products_id=' $orders['products_id']) . '">' $orders['products_name'] . '</a>');
         
                 
    $col ++;
                 if (
    $col 2) {
                   
    $col 0;
                   
    $row ++;
                 }
               }
         
               new 
    contentBox($info_box_contents);
         
    ?>
         <!-- also_purchased_products_eof //-->
         <?php
             
    }
           }
         
    ?>
    3. Now, the constant USE_CACHE is always set to false, therefore the above include is always executed.

    4. Here is the generated code when there are products also purchased.

    Code:
         <!-- also_purchased_products //-->
         </tbody></table><table border="0" cellpadding="0" cellspacing="0" width="100%">
           <tbody><tr>
     	<td class="infoBoxHeading" height="14"><img src="corner_left.gif" alt="" border="0" height="20" width="20"></td>
     	<td class="infoBoxHeading" height="14" width="100%">Customers who bought this product also purchased</td>
     	<td class="infoBoxHeading" height="14"><img src="corner_right.gif" alt="" border="0" height="20" width="20"></td>
           </tr>
         </tbody></table>
         <table class="infoBox" border="0" cellpadding="1" cellspacing="0" width="100%">
           <tbody><tr>
     	<td><table class="infoBoxContents" border="0" cellpadding="4" cellspacing="0" width="100%">
           <tbody><tr>
     	<td class="smallText" align="center" valign="top" width="33%"><a href="http://example.com/product_info.php/products_id/6"><img src="test27_bla_files/beverage_tn.jpg" alt="Beverage Gel Candles" title=" Beverage Gel Candles " border="0" height="100" width="100"></a><br><a href="http://example.com/product_info.php/products_id/6">Beverage Gel Candles</a></td>
     	<td class="smallText" align="center" valign="top" width="33%"><a href="http://example.com/product_info.php/products_id/7"><img src="test27_bla_files/cappuccino_tn.jpg" alt="Cappuccino Candles" title=" Cappuccino Candles " border="0" height="100" width="100"></a><br><a href="http://example.com/product_info.php/products_id/7">Cappuccino Candles</a></td>
     	<td class="smallText" align="center" valign="top" width="33%"><a href="http://example.com/product_info.php/products_id/25"><img src="test27_bla_files/mind_stimulation_tn.jpg" alt="Mind Stimulation Candles™" title=" Mind Stimulation Candles™ " border="0" height="100" width="100"></a><br><a href="http://example.com/product_info.php/products_id/25">Mind Stimulation Candles™</a></td>
           </tr>
           <tr>
     	<td class="smallText" align="center" valign="top" width="33%"><a href="http://example.com/product_info.php/products_id/24"><img src="test27_bla_files/chakra_balancing_tn.jpg" alt="Chakra Aligning Candles™" title=" Chakra Aligning Candles™ " border="0" height="100" width="100"></a><br><a href="http://example.com/product_info.php/products_id/24">Chakra Aligning Candles™</a></td>
     	<td class="smallText" align="center" valign="top" width="33%"><a href="http://example.com/product_info.php/products_id/3"><img src="test27_bla_files/preferred_customer.gif" alt="Preferred Customer Program" title=" Preferred Customer Program " border="0" height="100" width="100"></a><br><a href="http://example.com/product_info.php/products_id/3">Preferred Customer Program</a></td>
     	<td class="smallText" align="center" valign="top" width="33%"><a href="http://example.com/product_info.php/products_id/12"><img src="test27_bla_files/soy_tins_tn.jpg" alt="SoyLuscious ™ Soy Tin Travel Candles" title=" SoyLuscious ™ Soy Tin Travel Candles " border="0" height="100" width="100"></a><br><a href="http://example.com/product_info.php/products_id/12">SoyLuscious ™ Soy Tin Travel Candles</a></td>
           </tr>
         </tbody></table>
         </td>
           </tr>
         </tbody></table>
         <!-- also_purchased_products_eof //-->
         			</form>
         		  </td>
         		</tr>
         	  </tbody></table>
         	</td>
         <!-- body_text_eof //-->
    5. Here is the generated code when there are no products also purchased.

    Code:
         	  </tbody></table>
         	</form></td>
         <!-- body_text_eof //-->
    6. Regarding the code generated from the first 2 lines of step 5 above, whatever happened with the PHP code from step 1 as follows ???

    PHP Code:
                    </form>
                    </
    td>
                  </
    tr>
                </
    table>
              </
    td>
      <!-- 
    body_text_eof //--> 
    I assume browsers add tags in, well so I have noticed, but in particular, what happened to the code after the "</form></td>" ??

    It just doesn't make sense, there is no logical reason for the PHP not to write the html code as defined in the file.

    Hoping someone can shed some light on this please.

    Peter

  2. #2
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code is really hard to follow and does not appear to be complete scripts. If you simplified a little maybe we could follow what was going on.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2003
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Quote Originally Posted by arborint
    Your code is really hard to follow and does not appear to be complete scripts. If you simplified a little maybe we could follow what was going on.
    The PHP code that is included is the complete script, and that is what my concern is. If I pasted entire scripts, then it would be more complex, not simple as you requested.

    Here is the "very cut down problem".

    1. This php code is always executed.

    PHP Code:
                     </form>
                      </
    td>
                    </
    tr>
                  </
    table>
                </
    td>
            <!-- 
    body_text_eof //--> 
    Why is the generated html code like this when there are _no_ products also purchased:

    Code:
     </tbody>
     </table>
    </form>
     </td>
    <!-- body_text_eof //-->
    and yet, .. like this when there are products also purchased ??

    Code:
       </form>
    </td>
    </tr>
    </table>
    </td>
         <!-- body_text_eof //-->
    That is why I included the file 'also_purchased_products.php', step 2 from first post. That file is included _before_ the above code.

    Peter


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •