I'm writing a database driven admin tool (really, its basically just a GUI to manage the db). I have quite a bit of PHP, most of it mixed in with pure HTML, in use and have started breaking everything up into much smaller pieces to increase readability. However, while this works, I have no idea if this is a good idea, either based on convention or performance.
Here's an example. This code is repeated a bunch for each form field:
<?php
print '<div class="form-group">';
print '<label>Host Description</label>';
print '<textarea name="Description" class="form-control" rows="3">'.$_GET["Description"].'</textarea>';
print '</div>';
...code is repeated for other fields...
?>
I have started changing that to this:
<div class="form-group">
<label>Host Description</label>
<?php print '<textarea name="Description" class="form-control" rows="3">'.$_GET["Description"].'</textarea>';?>
</div>
...code is repeated for other fields...
When I say the code is repeated, I mean that different form fields and form field types are displayed one after the other.
Does this make sense? It makes the code much more readable with only the lines that need to be PHP part of the script. I have no idea what kind of conventions I'm breaking or performance hits I'm taking though. Is this a good idea? Bad idea?