Jump to content

Simple PHP problem from a PHP Newb

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
ironhorse

ironhorse

    Newbie

  • Members
  • Pip
  • 2 posts
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

#2
DEViANT

DEViANT

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 358 posts
If you can post the script up here I can try and help you

:D You should rep+ me so that I can win :D

My Blog | Ask me!
Error : Satan did it

#3
ironhorse

ironhorse

    Newbie

  • Members
  • Pip
  • 2 posts
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

#4
DEViANT

DEViANT

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 358 posts
try this :
$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.

:D You should rep+ me so that I can win :D

My Blog | Ask me!
Error : Satan did it