|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Clean coding, HTML but I feel like using PHP for this instead of CSS...
I have this table which is getting on my nerves. I love to look at the source code the browser generates and stare at all the perdy html tags while thinking of all the perdy PHP behind all of this
![]() I break in and out of PHP for my HTML in all my scripts because my friends and boss uses Dreamweaver and this way all the html shows up for them to change colors etc... and the PHP is shown in cute little yellow boxes marked with "PHP" ![]() Anyway I have this code, I want it to look neater! Code:
<tr height="23" onMouseOver="this.bgColor='#FFFFCC'" onMouseOut="this.bgColor=''">
<td width="176"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $pec; ?></font><img src="images/clear.gif" width="1" height="1"></td>
<td width="75"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $scode; ?></font><img src="images/clear.gif" width="1" height="1"></td>
<td width="72"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $cpc; ?></font><img src="images/clear.gif" width="1" height="1"></td>
<td width="207"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $description; ?></font><img src="images/clear.gif" width="1" height="1"></td>
<td width="200">
Notice all the face="blabla..." I could use CSS but it wouldn't work with all browsers. I was thinking of making a sort of CSS but with simple PHP vars what do you think? Got any ideas to make this table clean?
__________________
echo $lol; |
|
#2
|
||||
|
||||
|
How about a solution that I often apply:
Code:
<?php
$blob .= '
<tr>
<td width="176"><font size="'.$fontsize.'" face="'.$fontface.'">
'.$pec.'</font><img src="images/clear.gif" width="1" height="1">
</td>
</tr>';
?>
This way you generate one big variable, that print at the end of the page. It also allows you to embed php code easier, especially when you have very dynamic site and PHP dominates most of the source code.
__________________
-- Tomi Kaistila -- Developer's Journal The more you learn, the more you know. The more you know, the more you forget. The more you forget, the less you know. |
|
#3
|
|||
|
|||
|
That's what I was thinking but instead I'd use
Code:
$font1 = "<font size=1 face=\"blablabala\">"; $font2 = "</font>"; <?=$font1?>hey look at me LOL<?=$font2?> Still looks messy, I have to use it so that Dreamweaver can still display the tables and such. If I used $font for the open tag and </font> in the close tag DW will show a big ugly error. And I can't controll those settings on my boss's computer ![]() And as for it looking messy in the source code I think I will show it all in one line. It will be easier to read. I did remove the 1px images. Those are only for when the cell is empty, it displays a screwed up table in the browser. So I made some PHP code to put the img when the table vars ($pec, $scode, etc.) is empty. Code:
<!-- Final view -->
<tr height="23" onMouseOver="this.bgColor='#FFFFCC'" onMouseOut="this.bgColor=''">
<td width="176"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">ED1241-73 G22A</font></td>
<td width="75"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">150834</font></td>
<td width="72"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">B0091459</font></td>
<td width="207"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">AUX FRMG SUPP. TO WALL DRILLED Y.Z</font></td>
Thanks, I am being stubbern on this but I want to end result to be very clean and pro like since this is my first big project. |
|
#4
|
|||
|
|||
|
If anyone is interested (doubt it) but here is what I use to replace the $var if it is =="" Very simple... but do think this is a bad idea? To call a function like that?
Code:
//Used for replacing an empty var with a clear gif 1px X 1px
function replace_empty($vars) {
if ($vars =="") {
$vars = "<img src='images/clear.gif' width='1' height='1'>";
}
echo $vars;
} //End function replace_empty
//In my while loop...
<?php replace_empty($pec); ?>
I wonder if: if(empty($vars)) would do the same? Or is empty() sort of like isset()? I don't understand that 100%, maybe use both ($vars=="" || empty($vars)) LOL I dunno? Last edited by -=-steve-=- : December 12th, 2001 at 08:11 AM. |
|
#5
|
|||
|
|||
|
isset() checks if a variable is set or not. The semantics for empty is a bit more confusing. It returns true for empty strings and arrays and for objects with only empty properties. It does however return true for 0 but false for any other number, which can be annoying at times.
As for your problem, it sounds like it's about time you start using templates. I would also recommend that you use at least basic CSS, this is supported in most browsers. If you think of the typical 3 tier PHP application (DB -> Business Logic -> Presentation), you can split the presentation tier into to tiers; logical structure and layout. HTML is a markup language, after all, CSS is a pure layout language. This is by far the best organization, but it can be very tricky to get right, especially due to the lacking support for some of the more powerful CSS properties. Finally; display code is always messy, trying to clean it up with the purpose of making it look more appealing makes no sense to me, it's a total waste of time. The important issue is whether your applications are nicely structured or not. But again, your description screams for a template based solution.
__________________
-- Regards André Nęss Puritanism: The haunting fear that someone, somewhere may be having fun |
|
#6
|
|||
|
|||
|
Templates, yeah I may do that instead. The thing about source code around here is that some people who "think" they are code Gods (using FrontPage/DW) look at my source code (html output) and tell me that it isn't neat and nice to look at! LOL
How would templates work in a case like this? : Code:
PHP code for security... setting vars... <html> <body> <table> <tr> <td></td> <td></td> <td></td> </tr> PHP SQL, while loop... <tr> <td></td> <td></td> <td></td> </tr> PHP end while loop... </table> </body> </html> Thanks, Steve P.S. Do you know of a site that gives an idea which browser supports what as in JS, CSS? Maybe simple CSS would work in NS4.7? |
|
#7
|
|||
|
|||
|
I haven't worked with templates myself, but the general idea is that you can hand of HTML templates containing special codes to your designers. The designers can then either avoid the special codes, or learn how to use them. There are plenty of template engines out there, and I have no reason for recommending one over the other.
If your webdesigners tell you that the html is messy, then just tell them to go out and get some skills and then come back It has no impact on the result whatsoever. Maybe they call HTML "code" too?A nice resource on CSS support is: www.richinstyle.com (despite the rather ironic mismatch between name and design) For JS I'm not sure, I mostly stick to IE, but you will just have to use the reference from Netscape and MS, and see what is supported by who. The DOM and JS capabilities of IE are totally superior to those in Netscape. http://developer.netscape.com/docs/...jsref/index.htm http://msdn.microsoft.com/library/d.../doc_object.asp |
|
#8
|
|||
|
|||
|
Well I have to tell you that I am the web designer LOL and it's still rare that someone else will open DW to edit my HTML. I just want to make sure that if they do, I don't want DW to tell them that the HTML is wrong and such... Generally escaping PHP to print HTML has been working for me so far.
But some snoopy people will look at the view source and comment to me and my bosses and make me look stupid ![]() I try to tell them that my HTML is generated from my PHP code. I then printed out a script which was very nice looking, easy to read, well commented and such. But they don't get it... I'll forget them since I don't like the "know it all type". Heh! So I need an explaination here? I'm an Artistic Director originaly. I had a few graphic designers working for me. I take care of all the printed material from conception to pre-press. I do some graphic design also as in with the printed catalog design. Now I am a Webmaster also. What's a webdesigner: Only takes care of the look/content of the web site. Needing only HTML? Then webdevelopers: They take care of the scripts that run the dynamic site? And programmers? Are programmers only those who do client apps in C or C++? And not web applications done in PHP, Perl etc.. What is a webmaster supposed to do? Sorry for the basic and very stupid questions LOL Around here I do Graphic Design, Web Design, Web development, Graphic arts management (Artistic Director). Gee I need a raise? Thanks, Steve |
|
#9
|
||||
|
||||
|
A good idea could be to install into your Pc NN4.x (4.78, for example).
I have NN6.1 too. The same html code could render differently. Also if you like you could "validate" your html code at http://validator.w3.org/ (There are also validator offline, but I never used)
__________________
My article: mod_rewrite: No More Endless Loops! |
|
#10
|
|||
|
|||
|
WooHooo! Thanks for the link! I had a few stupid problems but I fixed them and voila, they are fussy as hell though!
"Congratulations, this document validates as HTML 4.01 Transitional!" That makes my day I printed the Congrats page along with some info on the W3C and showing that to my boss! ![]() Thanks, SG P.S. Now you'll make me want to spend more time and have every site validated hehe |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Clean coding, HTML but I feel like using PHP for this instead of CSS... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|