Enjoy an ad free experience by logging in. Not a member yet?
Register .
01-16-2010, 07:18 PM
PM User |
#1
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
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(" <font color='#008000'><strong>search results-on CLOCK CODE HERE</strong></font>")." ";
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";
01-16-2010, 07:45 PM
PM User |
#2
Senior Coder
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
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 ( " <font color='#008000'><strong>search results-on CLOCK CODE HERE</strong></font>" ). " " ;
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?
01-16-2010, 09:34 PM
PM User |
#3
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
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.
01-17-2010, 08:12 PM
PM User |
#4
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Anyone?
01-17-2010, 08:30 PM
PM User |
#5
Senior Coder
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,865
Thanks: 9
Thanked 291 Times in 287 Posts
does PHP run at all?
01-17-2010, 08:43 PM
PM User |
#6
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
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 :-(
01-17-2010, 08:45 PM
PM User |
#7
Senior Coder
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,865
Thanks: 9
Thanked 291 Times in 287 Posts
usually you put that in your top level script, so that it renders in the appropriate place.
01-17-2010, 08:49 PM
PM User |
#8
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
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(" <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>")." ";
if ($resultCount)
{
$resultFrom = ($offset+1);
$resultTo = ($offset+$config_resultsPerPage);
01-17-2010, 08:53 PM
PM User |
#9
New Coder
Join Date: Jan 2010
Location: UT
Posts: 35
Thanks: 1
Thanked 3 Times in 3 Posts
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 ( " <font color='#008000'><strong>search results-on " . $date1 . $date2 . "</strong></font>" ). " " ;
Let me know if this worked or not.
01-17-2010, 09:02 PM
PM User |
#10
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
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 :-)))))
01-17-2010, 09:08 PM
PM User |
#11
New Coder
Join Date: Jan 2010
Location: UT
Posts: 35
Thanks: 1
Thanked 3 Times in 3 Posts
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.
Users who have thanked Zoic for this post:
01-17-2010, 09:12 PM
PM User |
#12
New to the CF scene
Join Date: Jan 2010
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
:-) I will come back and let you know how I get on!
Thanks again.
Jump To Top of Thread
Thread Tools
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
HTML code is Off
All times are GMT +1. The time now is 08:13 AM .
Advertisement
Log in to turn off these ads.