Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Newb - Coding Question
Old 08-07-2009, 12:31 PM PHP Newb - Coding Question
Skilled Talker

Posts: 90
Trades: 0
Let me preface with - I'm a big newb.

On my next website I'd like to have the text in my H1 tag to automatically go into the header and maybe the title of the page. How do I do this?

Thank You
__________________

Please login or register to view this content. Registration is FREE
myshtern is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-07-2009, 02:17 PM Re: PHP Newb - Coding Question
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
The simplest of solutions would have to be something like this.

PHP Code:
<html>
<head>
<?php
$title 
"This is my title";
echo 
"<title>$title</title>";
?>
</head>
<body>
<h1><?php echo $title;  ?></h1>
<p>Some text...</p>
</body>
</html>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 08-14-2009, 03:28 AM Re: PHP Newb - Coding Question
Skilled Talker

Posts: 90
Trades: 0
lizciz thank you very much that did exactly what I need. I'm hoping I can take this a little bit further.

Let's say $title = "XYZ"
I have folder "XYZ" and in that folder I have "XYZ.jpg"

Can I do something like this -
<img src="/$title/$title.jpg">?

I know what I wrote above obviously won't work but is there a way to do it in php?

Thanks
__________________

Please login or register to view this content. Registration is FREE
myshtern is offline
Reply With Quote
View Public Profile
 
Old 08-14-2009, 05:04 AM Re: PHP Newb - Coding Question
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
<img src="<?php echo "/$title/$title.jpg"?>" />
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-14-2009, 05:12 AM Re: PHP Newb - Coding Question
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
The code you wrote will indeed work, if you have it withing the php tags, as in
PHP Code:
<?php
$title 
"XYZ";
echo 
"<img src=\"$title/$title.jpg\">"// Notic I have to escape the quotes inside the string
?>
And since you're new to php it may not be obvious, but you can insert php code anywhere in the document, for example by doing this

PHP Code:
<?php
$title 
"XYZ";
echo 
"<title>$title</title>";
?>
</head>
<body>
<p>Some html code here...</p>
<p>And then the image</p>
<?php
echo "<img src=\"$title/$title.jpg\">";
?>
</body>
</html>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to PHP Newb - Coding Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.99595 seconds with 12 queries