Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-16-2010, 07:18 PM   PM User | #1
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
How do I insert code into code

Hi all, I am a php newbie and a bit stumped. I am trying to insert a time and date peice of code into a php script to modofy it but I cannot get ti to work.
Please could someone give a pointer as to what is wrong here?

Many thanks :-)

Original code:

database_querySelect($sqlResultCount,$rows);

$resultCount = $rows[0]["resultcount"];

$banner["h2"] = translate("&nbsp;<font color='#008000'><strong>search results-on CLOCK CODE HERE</strong></font>")."&nbsp;";

if ($resultCount)
{
$resultFrom = ($offset+1);

$resultTo = ($offset+$config_resultsPerPage);

if ($resultTo > $resultCount) $resultTo = $resultCount;

and this is the php clock code to go where it says CLOCK CODE HERE:

echo date('l jS \of F Y \a\t ');
putenv("TZ=Europe/London");
echo date("h:i a")."\n";
tonto is offline   Reply With Quote
Old 01-16-2010, 07:45 PM   PM User | #2
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
What kind of error does it give you? also please use PHP code tags.

PHP Code:
database_querySelect($sqlResultCount,$rows);

$resultCount $rows[0]["resultcount"];

$banner["h2"] = translate("&nbsp;<font color='#008000'><strong>search results-on CLOCK CODE HERE</strong></font>")."&nbsp;";

if (
$resultCount)
{
$resultFrom = ($offset+1);

$resultTo = ($offset+$config_resultsPerPage);

if (
$resultTo $resultCount$resultTo $resultCount;

and 
this is the php clock code to go where it says CLOCK CODE HERE:

echo 
date('l jS \of F Y \a\t ');
putenv("TZ=Europe/London");
echo 
date("h:i a")."\n"
__________________
Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?
masterofollies is offline   Reply With Quote
Old 01-16-2010, 09:34 PM   PM User | #3
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
Sorry, there is no error displayed on the page it just doesn't display anything as if it isn't there.. By php tags do you mean the <?php-?> tags?

Thanks.
tonto is offline   Reply With Quote
Old 01-17-2010, 08:12 PM   PM User | #4
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
Anyone?
tonto is offline   Reply With Quote
Old 01-17-2010, 08:30 PM   PM User | #5
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,865
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
Macintosh

does PHP run at all?
Dormilich is offline   Reply With Quote
Old 01-17-2010, 08:43 PM   PM User | #6
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
Hello, thanks for replying, the page works fine but the problem is I do not know how to place the clock code into the other php code so that it will display.. Although the page works the clock does not show in the browser :-(
tonto is offline   Reply With Quote
Old 01-17-2010, 08:45 PM   PM User | #7
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,865
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
usually you put that in your top level script, so that it renders in the appropriate place.
Dormilich is offline   Reply With Quote
Old 01-17-2010, 08:49 PM   PM User | #8
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
So should it work if I just insert it like this-as it doesn't appear to?

database_querySelect($sqlResultCount,$rows);

$resultCount = $rows[0]["resultcount"];

$banner["h2"] = translate("&nbsp;<font color='#008000'><strong>search results-on <?php echo date('l jS \of F Y \a\t ');
putenv("TZ=Europe/London");
echo date("h:i a")."\n"; ?></strong></font>")."&nbsp;";

if ($resultCount)
{
$resultFrom = ($offset+1);

$resultTo = ($offset+$config_resultsPerPage);
tonto is offline   Reply With Quote
Old 01-17-2010, 08:53 PM   PM User | #9
Zoic
New Coder

 
Join Date: Jan 2010
Location: UT
Posts: 35
Thanks: 1
Thanked 3 Times in 3 Posts
Zoic is an unknown quantity at this point
You could do something like the following to get what your wanting.

PHP Code:
$date1 date('l jS \of F Y \a\t ');
putenv("TZ=Europe/London");
$date2 date("h:i a")."\n"

$banner["h2"] = translate("&nbsp;<font color='#008000'><strong>search results-on ".$date1.$date2."</strong></font>")."&nbsp;"
Let me know if this worked or not.
Zoic is offline   Reply With Quote
Old 01-17-2010, 09:02 PM   PM User | #10
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
Amazing, I cannot thank you enough, it worked perfectly straight away, I am going to try to learn more about php, I am familiar with javascript but php is new to me and seems a far better way of getting clever stuff into a page getting the server to do the work rather than the browser.

Thanks again :-)))))
tonto is offline   Reply With Quote
Old 01-17-2010, 09:08 PM   PM User | #11
Zoic
New Coder

 
Join Date: Jan 2010
Location: UT
Posts: 35
Thanks: 1
Thanked 3 Times in 3 Posts
Zoic is an unknown quantity at this point
Not a problem at all!

PHP is a really fun language and can do some amazing things. You're in for a treat if you ask me lol.
Zoic is offline   Reply With Quote
Users who have thanked Zoic for this post:
tonto (01-17-2010)
Old 01-17-2010, 09:12 PM   PM User | #12
tonto
New to the CF scene

 
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
tonto is an unknown quantity at this point
:-) I will come back and let you know how I get on!

Thanks again.
tonto is offline   Reply With Quote
Reply

Bookmarks

Tags
how to., insert, new code, php

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:13 AM.


Advertisement
Log in to turn off these ads.