PDA

View Full Version : PHP Title Script



Jojee
10-18-2008, 02:37 AM
Oookay. So I've been trying forever to make the title do what I want, and it seems like it should be simple! But I can't get it to work. @_@ So help. I promise I won't figure this out in 15 minutes and say "Never mind." xD

I stripped the page down to the basics. This is my script:
100 x 100 Avatars (http://neskaya.net/x/avatartest/code.txt)

This is the script in action:
100 x 100 Avatars (http://neskaya.net/x/avatartest/)

<b>Explanation</b>: What it does is basically pulls from each directory any avatars I upload and displays them on the site. There's the $catname variable which shows the name of the folder the avatars are in minus any underscores.

What I want is to also display the $catname in the title, but it doesn't work because I think it hasn't been declared and I tried a bunch of crap, and I'm confused? xD
For example, if you click the "Asian Girls" category, it takes you to the page. I can get the words "Asian Girls" to display on the page via $catname, and Asian_Girls is the name of the folder all of those avatars are in.
The title to all the pages right now is "100 x 100 Avatars." How would I get it to display "100 x 100 Asian Girls Avatars" instead, and modify for all of the other categories as well? :3

Um so if someone has a lot of time... xD Thanks~!

o_O
10-18-2008, 05:08 AM
You're right that it won't display in the title because it's not declared at that point. You could try to do as much processing as possible at the beginning of the script, before you output any HTML. That would make the value of $catname available when you need to set it in the title.

Also it's not related, you're missing your &lt;/head&gt; tag in that text file. I'm not sure if that's the same code as is running at the moment, but you might want to have a look. :p

Jojee
10-18-2008, 07:38 AM
Oh oops, I have a /head tag in the original. xD I just stripped everything down so it's pretty much the code.

And I still can't get it to work, I dunnno @_@ I've tried like everything already. I updated the code and the script at work in the first post, if you click them. Now it just completely messes up xD

Could you or anyone by any chance write out how to put it in the title for me? ;3

crono_logical
10-18-2008, 09:37 AM
Are you sure the contents of code.txt match index.php? It doesn't seem to be doing what the code says to me :p

Jojee
10-18-2008, 10:53 PM
It should be the same. xD I'm sure the coding isn't in correct form or whatever, but the point is that it works and I don't really care beyond that :p (Well not anymore that I messed it up by putting a bunch of PHP in the beginning but I can put it back later xD)

I just wanna know how to do the title thing ;_;

Krelian
10-19-2008, 12:29 AM
Aren't you already halfway there? When I click on any of those categories I see the name being displayed at the top. If you just put it inside the &lt;title&gt;-tag you should be all set.
In code.txt, line 115 change "h1" to "title" and the category is displayed as title. Unless I misunderstood that is what you wanted, isn't it?

Jojee
10-19-2008, 01:49 AM
Kinda, but oi you know what, you're right.

I could have avoided ALL this pain by just putting the title at the end of the page.

I've just... grown up learning that the title has to be in the &lthead&gt; section ;__; But it still displays if I put in or after the body. xD

Krelian
10-19-2008, 01:54 AM
Actually the title should still be inside the head-section. But it still is, if you follow my steps. In that line, the head-tag is still open, you would have to close it some lines later and open a body tag.

Samuraid
10-19-2008, 05:49 AM
Just a side note:

htmlspecialchars() is your friend. You might want to escape/sanitize your input ($_GET and such).