CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 12th, 2001, 07:21 AM
-=-steve-=- -=-steve-=- is offline
Devshed Gringo
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: Toronto, Ontario
Posts: 414 -=-steve-=- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 12 m 20 sec
Reputation Power: 8
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;

Reply With Quote
  #2  
Old December 12th, 2001, 07:35 AM
Datamike's Avatar
Datamike Datamike is offline
Web Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2001
Location: Finland
Posts: 719 Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 27 m 33 sec
Reputation Power: 9
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.

Reply With Quote
  #3  
Old December 12th, 2001, 07:52 AM
-=-steve-=- -=-steve-=- is offline
Devshed Gringo
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: Toronto, Ontario
Posts: 414 -=-steve-=- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 12 m 20 sec
Reputation Power: 8
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.

Reply With Quote
  #4  
Old December 12th, 2001, 08:09 AM
-=-steve-=- -=-steve-=- is offline
Devshed Gringo
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: Toronto, Ontario
Posts: 414 -=-steve-=- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 12 m 20 sec
Reputation Power: 8
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.

Reply With Quote
  #5  
Old December 12th, 2001, 08:32 AM
andnaess andnaess is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2001
Location: Oslo
Posts: 1,516 andnaess User rank is Private First Class (20 - 50 Reputation Level)andnaess User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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

Reply With Quote
  #6  
Old December 12th, 2001, 09:07 AM
-=-steve-=- -=-steve-=- is offline
Devshed Gringo
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: Toronto, Ontario
Posts: 414 -=-steve-=- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 12 m 20 sec
Reputation Power: 8
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?

Reply With Quote
  #7  
Old December 12th, 2001, 09:19 AM
andnaess andnaess is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2001
Location: Oslo
Posts: 1,516 andnaess User rank is Private First Class (20 - 50 Reputation Level)andnaess User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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

Reply With Quote
  #8  
Old December 12th, 2001, 09:40 AM
-=-steve-=- -=-steve-=- is offline
Devshed Gringo
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: Toronto, Ontario
Posts: 414 -=-steve-=- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 12 m 20 sec
Reputation Power: 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

Reply With Quote
  #9  
Old December 12th, 2001, 09:44 AM
pippo's Avatar
pippo pippo is offline
A PAtCHy sErver
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Italy
Posts: 410 pippo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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!

Reply With Quote
  #10  
Old December 12th, 2001, 10:27 AM
-=-steve-=- -=-steve-=- is offline
Devshed Gringo
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: Toronto, Ontario
Posts: 414 -=-steve-=- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 12 m 20 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Clean coding, HTML but I feel like using PHP for this instead of CSS...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway