View Single Post
Old 01-24-2013, 03:39 PM   PM User | #1
rgEffects
New Coder

 
Join Date: Aug 2012
Posts: 76
Thanks: 22
Thanked 0 Times in 0 Posts
rgEffects is an unknown quantity at this point
Php above or inside html?

My Standard practice has been to put a lot of my PHP queries before the Doctype and <head> tags on my pages. Things like <?php require_once (.... and query statements like this:
PHP Code:
mysql_select_db($database_civTekDB$civTekDB);
$query_companyMenuRS "SELECT id, type, category, `class`, link, approval, description FROM content WHERE approval = 'yes' AND category='company' AND class = 'subMenu' AND type  NOT LIKE '%private%' ORDER BY link ASC";
$companyMenuRS mysql_query($query_companyMenuRS$civTekDB) or die(mysql_error());
$row_companyMenuRS mysql_fetch_assoc($companyMenuRS);
$totalRows_companyMenuRS mysql_num_rows($companyMenuRS); 
Then after all of that, and it could be a couple hundred lines of code on a typical page I'll run the html. After the closing html tag at the bottom I'll put the free result for the queries like this:
PHP Code:
<?php
mysql_free_result
($pageRS);

mysql_free_result($currentUserRS);

mysql_free_result($masterLogRS);
?>
On the current site I'm working on there are a bunch of elements that may or may not show up on certain pages. Things like side menus, accordions, rotating banner add scripts, even different types of drop down menu's for different areas of the websites. I handle these using standard php include statements placed in the appropriate div tags in the HTML. They typically look like this:
PHP Code:
<div id="sideMenu">
    <?php include('includes/sideMenu.php'); ?>
</div>
Here's the question: Does it hurt anything to put all of that PHP that is usually before and after the HTML inside the includes that I place inside the HTML in div tags? It seems to work fine but is it slowing down the site or potentially causing other problems?

Thanks for your input.
rgEffects is offline   Reply With Quote