Jump to content

Display detail information


tbcomputerguy

Recommended Posts

I am an extremly novice at this php stuff. I have a file that displays a vehicle listing based on a xml feed. I am trying to add a link to another detail page by clicking on the words Full Detail (bolded below in the code) and send me to another page (index.php?option=com_content&view=article&id=6 (joomla)), the item detail page is based on the vehicle id and has the vehicle details show up. the detail page is also a xml file with the item info. I assume I have to use the <a href.... but how do I add the Id of the vehicle. Do I use a .($_Get['vehicleid']).

 

Follow me?

 

Partial Listing of Vehciles

 

$doc = new DOMDocument();
$doc->loadXML($output);
$vehicles = $doc->getElementsByTagName("vehicle");
//print_r($xmlarray);
$results = print_r($xmlarray, true);
echo $results;
foreach ($vehicles as $vehicle) {

    $vehicleIDs = $vehicle->getElementsByTagName("vehicleID");
    $vehicleID = $vehicleIDs->item(0)->nodeValue;
    $years = $vehicle->getElementsByTagName("year");
    $year = $years->item(0)->nodeValue;
    $makes = $vehicle->getElementsByTagName("make");
    $make = $makes->item(0)->nodeValue;
    $models = $vehicle->getElementsByTagName("model");
    $model = $models->item(0)->nodeValue;
    $prices = $vehicle->getElementsByTagName("price");
    $price = $prices->item(0)->nodeValue;
    $modelExts = $vehicle->getElementsByTagName("modelExt");
    $modelExt = $modelExts->item(0)->nodeValue;
    $conditions = $vehicle->getElementsByTagName("condition");
    $condition = $conditions->item(0)->nodeValue;
    $auxPhotoss = $vehicle->getElementsByTagName("auxPhotos");
    $auxPhotos = $auxPhotoss->item(0)->nodeValue;
    $transmissions = $vehicle->getElementsByTagName("transmission");
    $transmission = $transmissions->item(0)->nodeValue;
    $cylinderss = $vehicle->getElementsByTagName("cylinders");
    $cylinders = $cylinderss->item(0)->nodeValue;
    $fueltypes = $vehicle->getElementsByTagName("fueltype");
    $fueltype = $fueltypes->item(0)->nodeValue;
    $doorss = $vehicle->getElementsByTagName("doors");
    $doors = $doorss->item(0)->nodeValue;
    $financings = $vehicle->getElementsByTagName("financing");
    $financing = $financings->item(0)->nodeValue;
    $paymentFrequencys = $vehicle->getElementsByTagName("paymentFrequency");
    $paymentFrequency = $paymentFrequencys->item(0)->nodeValue;
    $kilometerss = $vehicle->getElementsByTagName("kilometers");
    $kilometers = $kilometerss->item(0)->nodeValue;
    $imgSrcs = $vehicle->getElementsByTagName("imgSrc");
    $imgSrc = $imgSrcs->item(0)->nodeValue;
    $formattedprice = sprintf("%01.2f", $price);
    $price_currency = number_format($price, 2, ".", ",");
    if ($price_currency == 0) {
        $price_currency = "CONTACT DEALER";
    }

    $featuress = $vehicle->getElementsByTagName("features");
    $features = $featuress->item(0)->childNodes;
    $featureCount = $features->length;
    $i = 0;
    $featurestring = "";
    while ($i < $featureCount) {
        $i++;
        $featureA[$i] = $features->item($i - 1)->nodeValue;
        $featurestring .= ($i % 2 == 0 ? $featureA[$i] . ", " : "");
    }
    
echo "<table style=background-color: rgb(246, 246, 246)text-align: left width: 900px height: 100px\n"; 
echo "    border=0 cellpadding=2 cellspacing=2>\n"; 
echo "    <tbody>\n"; 
echo "    <tr>\n"; 
echo "    <td\n"; 
echo "    style=background-color: black font-family: Helvetica,Arial,sans-serif><small><span\n"; 
echo "    style=color: yellow><span style=font-weight: bold>Vehicle ID:</span>\n"; 
echo "    $vehicleID</span></small></td>\n"; 
echo "    <td\n"; 
echo "    style=background-color: rgb(255, 204, 0) font-family: Helvetica,Arial,sans-serif width: 147px><small>Year:\n"; 
echo "    $year</small></td>\n"; 
echo "    <td\n"; 
echo "    style=background-color: rgb(255, 204, 0) font-family: Helvetica,Arial,sans-serif width: 109px><small>Make:\n"; 
echo "    $make</small></td>\n"; 
echo "    <td\n"; 
echo "    style=background-color: rgb(255, 204, 0) font-family: Helvetica,Arial,sans-serif width: 141px><small>Model:\n"; 
echo "    $model</small></td>\n"; 
echo "    <td\n"; 
echo "    style=background-color: black font-family: Helvetica,Arial,sans-serif width: 147px><small><span\n"; 
echo "    style=color: rgb(255, 204, 0) font-weight: bold>Price: $\n"; 
echo "    $price_currency</span></small></td>\n"; 
echo "    </tr>\n"; 
echo "    <tr>\n"; 
echo "    <td colspan=1 rowspan=3><small><span\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif><img src=$imgSrc></span></small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 147px><small>Condition:\n"; 
echo "    $condition</small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 109px><small></small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 141px><small></small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 147px><small></small></td>\n"; 
echo "    </tr>\n"; 
echo "    <tr width=147\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif>\n"; 
echo "    <small></small><td\n"; 
echo "    style=background-color: black width: 147px colspan=4 \n"; 
echo "    rowspan=1><span style=color: rgb(255, 204, 0)><a href=\"http://heavyequipmentwantedads.com/icardemo/inventory/getitems.php?&$vehicleID\" title=\"Full Details (View)\" target=\"_new\">Full Details (View)</a></span></td>\n"; 
echo "  	<small></small></tr>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 147px><small>Transmission\n"; 
echo "    : $transmission</small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 109px><small>Doors:\n"; 
echo "    $doors</small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 141px><small>FuelType: $fueltype</small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 147px><small>KM:\n"; 
echo "    $kilometers</small></td>\n"; 
echo "    </tr>\n"; 
echo "    <tr>\n"; 
echo "    <td style=background-color: rgb(204, 204, 204)><small></small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 147px><small>Cylinders:\n"; 
echo "    $cylinders</small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 109px><small></small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 141px><small>Features: $featurestring</small></td>\n"; 
echo "    <td\n"; 
echo "    style=font-family: Helvetica,Arial,sans-serif width: 147px><small></small></td>\n"; 
echo "    </tr>\n"; 
echo "    </tbody>\n"; 
echo "    </table>\n";

 

 

Partial listing of items:

 

<?php
$xmldata ='<dealerAccount>
<accountNum>xxxxxx</accountNum>
<dealerPwd>xxxxxxxxx</dealerPwd>
<data>item</data>
<vehicleID>'.$vehicleID.'</vehicleID>
</dealerAccount>';
$URL = "http://www.wheelsonline.ca/api/";

$ch = curl_init($URL);
//curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xmldata");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

$doc=new DOMDocument();
$doc->loadXML($output);
$items=$doc->getElementsByTagName("item");
$results = print_r($xmlarray, true);
echo $results;

?>

Link to comment
https://forums.phpfreaks.com/topic/230356-display-detail-information/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.