SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Great White North
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a little advice, please...

    Hi,

    I'm have developed a poll system that takes the result from a series of radio buttons and writes it to an XML file. I have broken it up into two components: survey.php and results.php

    survey.php writes to the XML file while results.php loops through the XML file and calculates the percentage of options selected.

    I have used an include to pull the survey.php file into my webpage.



    What I would like to do is to have the results.php page replace the survey.php page when I click on the link, instead of going to a new page as it does now.

    Is this possible to dynamically replace the file being inlcuded or do I have to use an Iframe?

    Thank you!
    hockeyunderground.net
    - Fantasy Hockey Depot

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you're already using XML you might want to take a look a the XMLHttpRequest object which is what Ajax is all about. Pear has a new module which I believe is in Beta:
    http://pear.php.net/package/HTML_AJAX

    Also, Yahoo just released a decent javascript library which has a component that looks good to help handle the XMLHttpRequest object on the javascript side:

    http://developer.yahoo.net/yui/

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Great White North
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jackreacher
    Since you're already using XML you might want to take a look a the XMLHttpRequest object which is what Ajax is all about. Pear has a new module which I believe is in Beta:
    http://pear.php.net/package/HTML_AJAX

    Also, Yahoo just released a decent javascript library which has a component that looks good to help handle the XMLHttpRequest object on the javascript side:

    http://developer.yahoo.net/yui/
    Thanks, but I would rather not open up another kettle of worms right now.

    I'm still trying to wrap my head around PHP let alone AJAX.
    hockeyunderground.net
    - Fantasy Hockey Depot

  4. #4
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    don't you mean can of worms?

    first, show us some code. and, second, from what I can tell, why don't you just tell survey.xml to display when the survey up and results.xml to display when the link is clicked, via a GET variable or something?
    Fesh
    imagine what it's going to be like

  5. #5
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have it post to a processing page
    Store the url it just came from in a variable.
    Have another variable set to "view_results" as opposed to "display" then redirect the user to the page with these variables appended to the URL.

    The include file should check for the variable (which should now be set to "view_results" and load the poll results based on it.

    Its roundabout and it won't work on pages with $_GET variables on them already (I think) but its the best you can do.

    Consider just displaying the poll on its own page, it'll give you more flexibility.

    I have something similar set up here.
    www.soulciti.com/news.php
    and I thought about doing it your way, but the hassle was a bit much.


    Quote Originally Posted by cob
    Hi,

    I'm have developed a poll system that takes the result from a series of radio buttons and writes it to an XML file. I have broken it up into two components: survey.php and results.php

    survey.php writes to the XML file while results.php loops through the XML file and calculates the percentage of options selected.

    I have used an include to pull the survey.php file into my webpage.



    What I would like to do is to have the results.php page replace the survey.php page when I click on the link, instead of going to a new page as it does now.

    Is this possible to dynamically replace the file being inlcuded or do I have to use an Iframe?

    Thank you!

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Great White North
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ikeo
    have it post to a processing page
    Store the url it just came from in a variable.
    Have another variable set to "view_results" as opposed to "display" then redirect the user to the page with these variables appended to the URL.

    The include file should check for the variable (which should now be set to "view_results" and load the poll results based on it.

    Its roundabout and it won't work on pages with $_GET variables on them already (I think) but its the best you can do.

    Consider just displaying the poll on its own page, it'll give you more flexibility.

    I have something similar set up here.
    www.soulciti.com/news.php
    and I thought about doing it your way, but the hassle was a bit much.
    Thanks for the advice. I was thinking about using a separate page as well but thought that my initial idea was a little more slick. But, as you say, its doesn;t seem to be worth the hassel. I'm still very new to PHP and am not aware of all of its capibilites, which makes it difficult for me to know whether or not my ideas are feasibile or not.

    Thanks again.

    COB
    hockeyunderground.net
    - Fantasy Hockey Depot


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •