Mixing HTML PHP and sharing Data between Scripts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve W

    Mixing HTML PHP and sharing Data between Scripts

    I tried searching first, but couldn't find an answer

    My first shot at PHP (what a cool language!)

    Wrote a quick script to query a server for xml data and plot it as
    points on a map

    Easy......, but then I wanted to take that same data set and create an
    IMAGE MAP in HTML via PHP so I could click on each data point

    It seems that imagepng won't work surrounded by HTML in the same code

    my work-around was to basically query the server once to create the
    plotted image, and then query the server again in a separate script to
    create the image map

    while this works, I am querying the server twice for the same data
    since I can't figure out how to share thte data with the script that
    creates the actual image and the script that creates the html image
    map

    here is sort of kind of what I would like to do....

    $URL = 'http://blahblahblah';
    $RawData = @file_get_conte nts("$URL");
    <HTML>
    <BODY>
    <img src="myscript.p hp?mode=MakeGra phic&data=$RawD ata"
    <map name="mymap">
    <?php myscript.php?mo de=MakeImageMap ?>
    <map>
    <BODY>
    </HTML>
  • Chung Leong

    #2
    Re: Mixing HTML PHP and sharing Data between Scripts

    If the number of points is small you can pass them to the image generating
    script through the URL. You can also use a session variable to hold the
    data, which is somewhat tricky because there're race hazards to consider.
    Unless the performance is unacceptable, I would stick with the solution you
    have now. The first query would probably be cached by your db server, so the
    second query isn't as expensive as you think.

    Uzytkownik "Steve W" <zacware@comcas t.net> napisal w wiadomosci
    news:d56dfbc8.0 403231630.6f55e 412@posting.goo gle.com...[color=blue]
    > I tried searching first, but couldn't find an answer
    >
    > My first shot at PHP (what a cool language!)
    >
    > Wrote a quick script to query a server for xml data and plot it as
    > points on a map
    >
    > Easy......, but then I wanted to take that same data set and create an
    > IMAGE MAP in HTML via PHP so I could click on each data point
    >
    > It seems that imagepng won't work surrounded by HTML in the same code
    >
    > my work-around was to basically query the server once to create the
    > plotted image, and then query the server again in a separate script to
    > create the image map
    >
    > while this works, I am querying the server twice for the same data
    > since I can't figure out how to share thte data with the script that
    > creates the actual image and the script that creates the html image
    > map
    >
    > here is sort of kind of what I would like to do....
    >
    > $URL = 'http://blahblahblah';
    > $RawData = @file_get_conte nts("$URL");
    > <HTML>
    > <BODY>
    > <img src="myscript.p hp?mode=MakeGra phic&data=$RawD ata"
    > <map name="mymap">
    > <?php myscript.php?mo de=MakeImageMap ?>
    > <map>
    > <BODY>
    > </HTML>[/color]


    Comment

    Working...