How to create page with php loop

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:

<AD> <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> </AD>

I am assuming the ADID would identify each loop. Here is a sample from my loop:

[code]<?php

error_reporting(-1);

$preowned = simplexml_load_file(‘file.xml’);
foreach ($preowned as $preownedinfo)
{
$price = ‘$’ . money_format($preownedinfo->Price, 2, ‘.’, ‘,’);

$photosHTML = '';
foreach ($preownedinfo->AditionalPhoto as $addphoto)
{
    $photosHTML .= "<li>$addphoto</li>";
}

echo "
{$preownedinfo->Yrs} {$preownedinfo->Make} {$preownedinfo->Model} {$preownedinfo->ExtraField->ContentEN->ExteriorColor} {$preownedinfo->ExtraField->ContentEN->Doors} Doors
";

}

?> [/code]

I just am unsure at this point as to what I should even google. Any help would be greatly appreciated!!

Instead of making a script to dynamically create page with your XML file, make a script to take the information provided from the XML file and store it into a database. But if you don’t want that, you’re going to have to be able to relate your companies through an id which I see you have : ADID so you should be able to relate your data though don’t quote me on this, I don’t know exactly how simplexml_load_file works.

You want your obj to look like
[php]ADID - > Info
ADID -> Info
[/php]

Then you can relate your companies and loop through the object setting [php]if($_GET[‘adid’] == $blah->ADID){//Do things}[/php]

I didn’t write out everything because you should learn this yourself, but I hope this at least sent you in the right direction.

Sponsor our Newsletter | Privacy Policy | Terms of Service