Re: better way to mix html and php code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Curt Zirzow wrote:
> On Wed, Nov 16, 2005 at 10:12:53AM -0600, afan@xxxxxxxx wrote:
> 
>>Hi to all,
>>always wondered what's better way to mix html and php code. Here are 
>>three "ways" of the same code. Which one you prefer? (And why, of caurse :))
>>

Personally, I present solution 2b.  I also don't like the idea of
a(nother) templating language either.  When doing html like this I also
like using short tags because it looks better and the colon syntax for
ifs as I find it easier for non-programmers and easier to follow in
large blocks of html.  That should be enough to get everyone here screaming.

I would also wrap this file inside a layout script and/or use prepend
and append files.  Depending on the overall use I'd consider pushing
some of it into another file.  There is too much php code in there at
the moment.

David

Solution 2b:
############################################################################################

<table class="table-heading"><!-- should probably be a div -->
	<tr>
		<td>
 			<?=$cat_parent_name?> ::
 			<?=$cat_id_name?>
 		</td>
 		<td>
 			<a href="new_product.php?cat_id=<?php echo $cat_id
?>&cat_parent=<?php echo $cat_parent?>">[ Add New Product ]</a>
 		</td>
 	</tr>
</table>

<table class="table-results">
<? foreach ($products as $product): ?>
  	<tr>
 		<td class="prod_name">&raquo; <?=product_name'?></td>
 		<td class="prod_no">[ <?=$product_number?> ]</td>
 		<td class="prod_action">
 			<img src="../images/icon_edit2.gif" alt="EDIT" width="14" height="14">

 			<a onclick="return confirm('Do you really want to delete this
product?');"
 				href="<?=$del_link?>">
 				<img src="../images/icon_delete.gif" alt="DELETE" width="14"
height="14">
 			</a>

 			<? if($status_link): ?>
 				<a href="<?=$status_link?>">
 					<img src="../images/status_<?=$status_img?>.gif"
 						alt="<?=$status_img?>" width="13" height="13">
 				</a>
 			<? else: ?>
				<img src="../images/status_<?=$status_img?>.gif"
 					alt="<?=$status_img?>" width="13" height="13">
 			<? endif; ?>

 		</td>
 	</tr>

<? endforeach; ?>
</table>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux