Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Page 1 of 2 1 2 >
Topic Options
#207469 - 27/02/2004 15:01 Some web authoring help
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
I am completely redoing my personal site, just because it's time for a little change. It's been the same for nearly three years, and instead of changing the colors a little bit and moving things around, I'm starting from scratch so I can do it right. I need some help though.

I've been fooling around with HTML for about 5 or 6 years now, but I've never been neat with it. Sure, I indent my tables and everything fine, and I have no problem finding what I need in my own code, but I want to code right. Not only that, but I want to be fully compliant. I read up on how to be XHTML compliant, and that's what I'm aiming for. It won't be too hard, as I've always done most of the things that make it more strict anyway. I always write tags in lower-case, put quotes around my values, and close tags properly. The main difference is that now I'll be writing different empty elements (<br />).

So, I've read up on the DTD stuff (I assume I'll use "transitional"), and now I want to know what I need to do to be fully HTML 4.01 compliant.

Lastly, I need to know a couple PHP things. First the large one: how do I do this "page creation on the fly" thing. I don't really understand it.

The other thing I want to know is just a code thing. I was wondering if there is a way for a page to know where it is on the server, or the address it's at. For instance, I want a page that's loaded to know which directory on my site it is in.

Thanks, I know this is a lot, but I'm just starting this whole process over and I want to do it right this time. This is what happens when you learn HTML by starting with Frontpage . Don't worry, I only used it for a few months, but I've been trying to correct myself ever since.
_________________________
Matt

Top
#207470 - 27/02/2004 17:05 Re: Some web authoring help [Re: Dignan]
ricin
veteran

Registered: 19/06/2000
Posts: 1495
Loc: US: CA
The other thing I want to know is just a code thing. I was wondering if there is a way for a page to know where it is on the server, or the address it's at. For instance, I want a page that's loaded to know which directory on my site it is in.


Those types of things are in $_SERVER.

Put this in a page to see them all:


<PRE>
<?php print_r($_SERVER); ?>
</PRE>

_________________________
Donato
MkII/080000565
MkIIa/010101253
ricin.us

Top
#207471 - 27/02/2004 20:54 Re: Some web authoring help [Re: ricin]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
This only works on a PHP-enabled web page and server, as should be obvious, but was not pointed out explicitly.
_________________________
Bitt Faulk

Top
#207472 - 28/02/2004 03:00 Re: Some web authoring help [Re: wfaulk]
ricin
veteran

Registered: 19/06/2000
Posts: 1495
Loc: US: CA
Right. He said:
Lastly, I need to know a couple PHP things.
And then listed two things.
So I was assuming he wanted to know how to do that in PHP.
_________________________
Donato
MkII/080000565
MkIIa/010101253
ricin.us

Top
#207473 - 28/02/2004 04:22 Re: Some web authoring help [Re: Dignan]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5680
Loc: London, UK
I want a page that's loaded to know which directory on my site it is in.

One question: Why? Maybe there's a better way to achieve what you're trying to do.
_________________________
-- roger

Top
#207474 - 28/02/2004 14:59 Re: Some web authoring help [Re: Roger]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Well, I want to have one bit of code for my menu, like I've had before. I want to have the button for the appropriate section to be different when you're on one of those pages. I was just going to find a way for the page to know where it was loaded, then load the appropriate image for that button at that point. If there's another way to do it I'm open to suggestion!

And as I said, I'd like to try this "on the fly" thing that people keep mentioning. Not sure what they mean though.
_________________________
Matt

Top
#207475 - 29/02/2004 16:52 Re: Some web authoring help [Re: Dignan]
David
addict

Registered: 05/05/2000
Posts: 623
Loc: Cambridge
When most web types talk about 'on-the-fly' page generation, they just mean that the page is built from a number of elements, usually pulled from a database specifically for the person making the request for that page.

Almost every page you write with some PHP in it can be considered to be generated 'on-the-fly'. A good example would be a basic page containing a news story. The client calls the page with the URL news.php?id=10. Your server goes to the news.php page, runs an SQL query and pulls the news story in from the database, inserts it into the middle of some HTML and returns that page to the client.

Top
#207476 - 29/02/2004 17:02 Re: Some web authoring help [Re: David]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
That makes sense. I guess I'm doing some of that already. Would includes count in that way?
_________________________
Matt

Top
#207477 - 29/02/2004 17:11 Re: Some web authoring help [Re: Dignan]
David
addict

Registered: 05/05/2000
Posts: 623
Loc: Cambridge
I was just going to find a way for the page to know where it was loaded, then load the appropriate image for that button at that point. If there's another way to do it I'm open to suggestion!


I typically write my sites to run from a wrapper script. This means that the URL always contains the section of the site you are in and it can simply be called by looking at the variables passed to the script, rather than the actual file being loaded.

For example:

index.php?f=about instead of about.php
index.php?f=news instead of news.php

To the user, it looks like the entire site is running from one huge script, but in your index.php script, simply put the line:

include($f.'.php');

This will just load the file named news.php. You'll want some error handling code here - check that the file exists and if it doesn't default to something like home.php.

For your navigation, you can now work out what page you are on simply by looking at the content of $f.

Another benefit of using wrapper scripts is that you can call commonly used code in one place, so you don't need to have include calls and database connection code at the top of every script.

Top
#207478 - 29/02/2004 17:16 Re: Some web authoring help [Re: David]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Thanks, that's an interesting idea, and I'm sure I could get it to work, but what do I do about my Gallery and message boards? That wouldn't really work, would it?
_________________________
Matt

Top
#207479 - 29/02/2004 17:21 Re: Some web authoring help [Re: Dignan]
David
addict

Registered: 05/05/2000
Posts: 623
Loc: Cambridge
Includes count, but I suppose it's really anywhere that you return something based on what the user has requested, such as content from a database, do an if/else, or return something that changes constantly like the current date and time.

I tend to refer to this type of thing as 'dynamic' pages.

Top
#207480 - 29/02/2004 17:26 Re: Some web authoring help [Re: Dignan]
David
addict

Registered: 05/05/2000
Posts: 623
Loc: Cambridge
It really depends on how the gallery and message board scripts work. There's lots of ways to get around that though.

Top
#207481 - 29/02/2004 17:45 Re: Some web authoring help [Re: David]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Not sure what you'd look for in how they work, but I would think it would be difficult to use this method since the board is generating its own links.

I'm not sure I like the idea of a wrapper, because I like to be organized by directory and such, and I kind of like the users to see that reflected in the address, but I'll think about it.

I just remembered something. Gallery and the message board have their own style sheets, so maybe I could try to do something with that for those sections.
_________________________
Matt

Top
#207482 - 01/03/2004 07:06 Re: Some web authoring help [Re: Dignan]
David
addict

Registered: 05/05/2000
Posts: 623
Loc: Cambridge
I'm not sure I like the idea of a wrapper, because I like to be organized by directory and such, and I kind of like the users to see that reflected in the address, but I'll think about it.

That's where mod_rewrite comes in. You can make a URL of http://www.site.com/news/23/ map to http://www.site.com/index.php?f=news&id=23.

There's a tutorial here: http://www.alistapart.com/articles/succeed/

Top
#207483 - 01/03/2004 13:06 Re: Some web authoring help [Re: David]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
I see. That's interesting, and I'll read up on that, but I'd just like to ask why simply reading the $SCRIPT_URL variable isn't the way to go? Seems more simple to me.
_________________________
Matt

Top
#207484 - 02/03/2004 19:36 Re: Some web authoring help [Re: Dignan]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
So I've worked out the menu thing using part of the PHP solution Ricin posted at the top of the thread.

Now I need some standards help. I've not had too much of a problem with the XHTML transition, except for one thing that they have made incredibly difficult: table height.

Okay, so the HTML table height tag has deprecated. But they've made it so that it is far more difficult to do using CSS. Why? This is incredibly frustrating.

So I have a table 750 pixels wide which I want to fill the page. This table only has two rows, the top one with a menu 60 pixels high, and the bottom one I want to expand to the size of the current area. In order to get the table to expand at all, I had to have this in the style sheet:

html, body
{
text-align: center;
margin: 0px;
padding: 0px;
height: 100%
}

I'm doing this entirely in styles now, because I've been told to So I have a class for the table with 'height: 100%', and class for the cells in the first row (three of them) all with 'heigh: 60px'. In old, lenient, HTML (in IE, at least), this would automatically expand the bottom row to fill out the 100% specified for the table. This does, in fact, make a table that fits 100% of the screen, but the top row has been pulled taller, and the two rows don't even match in size! Even when I take out the height for the top row, when I should get a result of two rows each taking up half of the screen, it's the same odd size as before.

So, I put the 60px height back in for the top row, and try adding a 100% to one of the cells on the bottom (still using classes). This time everything initially looks like it should, with the menu the correct height and the bottom row filling the rest of the screen, but then I notice that I have a vertical scrollbar. Turns out that the 100% for the bottom row meant 100% of the entire page and not just what was left after the 60px is taken out.

So I ask two things: first, how do I do what I'm trying to do using CSS? and second, why in God's name is this supposed to be better? Using simple HTML I could do this with absolutely no problem whatsoever. Yes, browsers displayed things differently, but as far as I could see that was the fault of the browsers and not the standard. It's a standard that wasn't lived up to. Why is this supposed to be different, and why the hell did they make it so difficult??
_________________________
Matt

Top
#207485 - 02/03/2004 22:22 Re: Some web authoring help [Re: Dignan]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I couldn't figure out how to do it with tables, but you can do it with divs in strict mode:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">

<html>
<head>
<title>
table test
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
html,body {
background: blue;
text-align: center;
margin: 0px;
padding: 0px;
height: 100%;
}
</style>
</head>
<body>
<div style="height: 100%; border: 10px solid #000000">
<div style="height: 60px; border: 10px solid #FF0000">upper</div>
lower</div>
</body>
</html>
Also note that you don't have to have styles defined for elements; you can put CSS stuff directly in the style attribute.
_________________________
Bitt Faulk

Top
#207486 - 02/03/2004 23:57 Re: Some web authoring help [Re: wfaulk]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Oh, wait. I see how to do it with tables:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>
table test
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
html,body {
text-align: center;
margin: 0px;
padding: 0px;
height: 100%;
}
</style>
</head>
<body>
<table border="1" style="height: 100%; width: 100%">
<tr style="height: 60px"><td>top</td></tr>
<tr style="height: 100%"><td>bottom</td></tr>
</table>
</body>
</html>
I'd forgotten to give the table a style height of 100% as well as the other elements.
_________________________
Bitt Faulk

Top
#207487 - 03/03/2004 00:19 Re: Some web authoring help [Re: wfaulk]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Oh hey! I wasn't aware that you could put styles on the rows instead of the cells. Interesting.

*edit*
well, I tried what you posted and got the same problem I had in the end the way I did it before. Did you get a scroll bar and about 60px of space to scroll down?


Edited by DiGNAN17 (03/03/2004 02:15)
_________________________
Matt

Top
#207488 - 03/03/2004 07:55 Re: Some web authoring help [Re: Dignan]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Nope. But, then, I was trying under OmniWeb.

It seems that IE is the only one that does it wrong.

These people seem to have come to the same conclusion.

Wow. Try resizing the IE window vertically. Making it smaller causes the 100% row to remain the same size. Making it larger causes the 100% row to grow to always be too big. I'd say that this is a huge bug in IE. Period. That doesn't help you, since most of your users will have the same bug, but it seems to be the case.


Edited by wfaulk (03/03/2004 08:14)
_________________________
Bitt Faulk

Top
#207489 - 03/03/2004 08:47 Re: Some web authoring help [Re: Dignan]
Cybjorg
addict

Registered: 23/12/2002
Posts: 652
Loc: Winston Salem, NC
Try this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>
table test
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
html,body { text-align: center; margin: 0px; padding: 0px; height: 100%; }
table.mytable { width: 100%; height: 100% }
td.hundred { width: 100%; height: 100%; vertical-align: top; border: solid 2px #000 }
td.sixty { width: 100%; height: 60px; vertical-align: top; border: solid 2px #000 }
</style>
</head>
<body>
<table class="mytable">
<tr><td class="sixty">top</td></tr>
<tr><td class="hundred">bottom</td></tr>
</table>
</body>
</html>



Top
#207490 - 03/03/2004 09:17 Re: Some web authoring help [Re: Cybjorg]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
FWIW, that does the exact same thing for me: works everywhere but IE.
_________________________
Bitt Faulk

Top
#207491 - 03/03/2004 09:45 Re: Some web authoring help [Re: wfaulk]
Cybjorg
addict

Registered: 23/12/2002
Posts: 652
Loc: Winston Salem, NC
Perhaps I am misunderstanding what it is that is trying to be accomplished. We don't want the vertical scrollbar on the right hand side, but rather the bottom of the table coming to the bottom of the viewable window?

Top
#207492 - 03/03/2004 09:56 Re: Some web authoring help [Re: Cybjorg]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Right. That's how Mozilla 1.5, Firefox 0.8, and OmniWeb 4.5 all render that code, but not IE, which seems to tack on an additional 60px, so that the entire table can never be seen all at once. In other words, it assumes that 100% is an immutable size unchanged by any other elements on the page.
_________________________
Bitt Faulk

Top
#207493 - 03/03/2004 10:05 Re: Some web authoring help [Re: wfaulk]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4172
Loc: Cambridge, England
In other words, it assumes that 100% is an immutable size unchanged by any other elements on the page.
Don't get me started on wonky table layout algorithms in mainstream browsers.

Peter

Top
#207494 - 03/03/2004 10:09 Re: Some web authoring help [Re: peter]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I think it all works right if you use divs, though. The first example above works perfectly if you remove the border of the outermost div, otherwise, it overdraws by the height of the top and bottom borders. I'm not quite sure how to do side-by-side with divs, but I'm sure it's easily possible.


Edited by wfaulk (03/03/2004 10:16)
_________________________
Bitt Faulk

Top
#207495 - 03/03/2004 15:01 Re: Some web authoring help [Re: wfaulk]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Thanks for all the work, Bitt. I appreciate it. It figures that I'm trying to adopt the standard, and now IE screws me over. My experience has usually been that IE renders things more logically than other browsers. Of course, it's probably becuase it was being more lenient than other browsers, which isn't all that great to begin with.

Grr. Frustration. I guess I won't have it fill the screen. Adding a bottom border of some sort to my pages is better than confusing my IE users with extra space that doesn't contain anything.
_________________________
Matt

Top
#207496 - 03/03/2004 15:04 Re: Some web authoring help [Re: Dignan]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
probably becuase it was being more lenient
I'm of the opinion that one should run every HTML page through http://validator.w3.org.
_________________________
Bitt Faulk

Top
#207497 - 03/03/2004 15:06 Re: Some web authoring help [Re: wfaulk]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
I would have done that before, but I was still recycling very old code from when I didn't care about following the standards at all. If it worked and displayed correctly for me, I didn't care.

Now that I'm following the standards, I definitely plan on running it through the validator. My style sheets too.
_________________________
Matt

Top
#207498 - 03/03/2004 15:46 Re: Some web authoring help [Re: Dignan]
foxtrot_xray
addict

Registered: 03/03/2002
Posts: 687
Loc: Atlanta, Georgia
Uhm, try this:

<table width="100% height="100%">
<tr>
<td height="60px">Cel 1</td></tr>
<tr>
<td>Cel 2</td>
</table>

Edit/add/change rows/columns as necessary.. Any cels in the top row that should only be 60px high, add the "height='60px'". The cels of the table that "expand" to the rest of the table, DO NOT add a 'height' tag. Using styles on table sections, I've found, ruins it..

Me.
_________________________
Mike 'Fox' Morrey 128BPM@124MPH. Love it! 2002 BRG Mini Cooper

Top
Page 1 of 2 1 2 >