Hey there.
What I'm trying to do is but some stock data and market information at the top of each page.
I've got a script that will do that. So in this case let's call this <?php [x]; ?>, this function dynamically returns live stock data. Now that trick is I want this data to be STATIC not dynamic, which is the problem I'm having.
So what happens is I insert <?php [x]; ?> at the top of my page and it constantly returns the latest stock data live. I want it to only to do that ONCE. This is being done for a WP blog, so at the top of each post will go the stock data at the time of the post.
I need a way for this function <?php [x]; ?> which every time the post is loaded returns a dynamic value, to return a static value.
I cannot modify this script <?php [x]; ?> as it is beyond my ability, but I'm sure there is an easy way to execute it and then simply post the return as basic HTML, I just don't know it.
Thanks for all your help and sorry if this is a stupid question.
IH
Simple PHP problem from a PHP Newb
Started by ironhorse, Dec 04 2010 05:57 PM
3 replies to this topic
#1
Posted 04 December 2010 - 05:57 PM
|
|
|
#2
Posted 04 December 2010 - 10:49 PM
If you can post the script up here I can try and help you
#3
Posted 05 December 2010 - 12:27 AM
Posting the script would be VERY long, I can do it, but I wondering if there is an easier fix without going down that road.
I'm using wordpress and trying to incorporate this at the top of each post.
<?php
echo get_stock_data(a, b, c,);
?>
get_stock_data(); returns the stock data
The problem is when I post this in wordpress as part of a post or the post template, it is then grabbing get_stock_data(a, b, c,) every time. I just want it to grab get_stock_data(a, b, c,) once and add it as HTML thus getting a static piece of data, not keep adding it as PHP and therefore making it dynamic.
Does that help a bit?
Thanks for any advice.
IH
I'm using wordpress and trying to incorporate this at the top of each post.
<?php
echo get_stock_data(a, b, c,);
?>
get_stock_data(); returns the stock data
The problem is when I post this in wordpress as part of a post or the post template, it is then grabbing get_stock_data(a, b, c,) every time. I just want it to grab get_stock_data(a, b, c,) once and add it as HTML thus getting a static piece of data, not keep adding it as PHP and therefore making it dynamic.
Does that help a bit?
Thanks for any advice.
IH
#4
Posted 05 December 2010 - 01:05 AM
try this :
And then after each post you just echo $stockvar since the function will then only by initiated once, saved to a variable, and then have the variable echo'd each time.
$stockvar = get_stock_data(a,b,c);
And then after each post you just echo $stockvar since the function will then only by initiated once, saved to a variable, and then have the variable echo'd each time.


Sign In
Create Account

Back to top









