Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2013
    Thanked 0 Times in 0 Posts

    Creating a separate page from a loop

    Would anybody be able to assist. I am at a loss. I am trying to figure out php while trying to parse an xml file. I have to create listings of automobiles. The loop I created to parse the details for each automobile needs to show on its own page. I have figured out I am to use the $_GET function, but I am not sure how to make that loop its own page. It right now shows as one listing after the other on the page. Here is a sample of the info for one automobile on the xml file:
     <ADID displayName="ADID">10456241</ADID>
     <CompanyID displayName="CompanyID">41382</CompanyID>
     <CompanyName displayName="CompanyName">GName</CompanyName>
     <Category displayName="Category">Sport Utility</Category>
     <StockNumber displayName="StockNumber">j08669</StockNumber>
    I am assuming the ADID would identify each loop. Here is a sample from my loop:
      $preowned = simplexml_load_file('file.xml');
      foreach ($preowned as $preownedinfo)
           echo "
     <div class=\"detailsTitle\">
         <a href=\"#\">{$preownedinfo->Yrs} {$preownedinfo->Make} {$preownedinfo->Model} {$preownedinfo->ExtraField->ContentEN->ExteriorColor} {$preownedinfo->ExtraField->ContentEN->Doors} Doors</a>
    So, I need this loop to be created as its own page and I will link to it from another page.
    I just am unsure at this point as to what I should even google. Any help would be greatly appreciated!!

  2. #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Thanked 100 Times in 100 Posts
    using a get filter:

    if your page was called xml.php:

    browse to
    PHP Code:
    contents of xml.php:
    PHP Code:

    $nodes $xml->xpath("//AD[contains(ADID, $page)]");
    $nodes as $node)
    $node as $name => $prop) {
    printf("%s: %s\n"$name$prop);
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month


Posting Permissions

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