Re: php+html mixup in displaying multidimensional array in html tables [message #176849 is a reply to message #176840] |
Sat, 28 January 2012 20:43 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
John wrote:
> I am new to this problem and shall be very grateful for any hint on how
> to a´void an unreadable code-salad, when trying to display a
> bidimensional array (thus with two indexes) on a html table.
> I refer to the continuous shifting between <?php and <html> every two
> lines.
You mean `<?php' and `?>'; there can be only one `<html>' tag in a (Valid)
HTML document.
Contrary to common misconception, several `<?php's and `?>'s in a file
parsed by PHP are healthy and appropriate, as it is the most efficient
method (stdin --> stdout) and the easiest to maintain (no quoting necessary;
parsing, that includes syntax highlighting and client-side validation, just
works both for HTML and PHP).
Only make sure that you do not mix too much program logic with the output
(loops are OK). Use the template approach (not necessarily a full-blown
template system like Smarty). And, as always, indent your code so that you
can tell sections apart.
RTFM: <http://www.php.net/manual/en/tutorial.firstpage.php>
> Is there a method which is 'quick an easy' to do the job ?
Yes. You have found it.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
|
|
|