Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying consumed information in PHP

Status
Not open for further replies.

ASPNETnewbie

Programmer
May 9, 2006
93
US
Hi,

The code below is supposed to consume and display vacation rental information from but for some reason, I don't think I have it formated right to display. I want to have the pictures and values returned displayed in a formatted method and so far have not been able to get the information to actually display. it works and there is information contained in the $xml when dumped. please help with formatting needs.

thanks in advance

Php Newbie




Code:
<?php

displayVastVacation("60110232599273101012125456212315","Columbus");

function displayVastVacation($apiKey,$Location)
{
$paramaters = array();
$endPoint = "[URL unfurl="true"]http://api.vast.com/?";[/URL]
$paramaters[] = array("api_method", "Vacation_Rentals");
$paramaters[] = array("key",$apiKey);
$paramaters[] = array("tlocation", $Location);
$paramaters[] = array("fresh_to","50");
$paramaters[] = array("sort", "3");

foreach ($paramaters AS $paramater)
{
 $endPoint .= $paramater[0] . "=" . $paramater[1] . "&";
}
// remove the & overflow to be sure the URL was created right
// $endPoint= substr_replace($endPoint,"", strlen($endPoint)-1);
//print out constructed XML to be sure it is correctly formatted
//echo $endPoint;
//query the server and get the response from the server
$response = file_get_contents($endPoint);

//echo utf8_decode($response);
$xml = simplexml_load_string($response);
echo"<table style=\"WIDTH:50%; POSITION: absolute; HEIGHT: 269px\"><tbody>";
//var_dump($xml);


foreach($xml->results->result{0} as $item)
{
 
$title=$item['title'];
$url=$item['url'];
$domain_name=$item['domain_name'];
$us_state=$item['us_state'];
$city=$item['city'];
$state=$item['state'];
$country=$item['country'];
$amenities=$item['amenities'];
$bedrooms=$item['bedrooms'];
$bathrooms=$item['bathrooms'];
$currency=$item['currency'];
$proptype=$item['proptype'];
$activities=$item['activities'];
$hasimage=$item['hasimage'];
$imageurl=$item['imageurl'];
$dupcount=$item['dupcount'];
$description=$item['description'];
	
	echo"<tr><td rowspan=\"3\">";
	echo "<img src=\"{$imageurl}\" align=\left\">";
	echo"</td><td colspan=\"2\">";
	echo "<a href=\"{$url}\" title=\"vacation\">{$title}</a>"."Location:{$city},{$state}<br>";
	echo"</td></tr><tr><td colspan=\"2\">";
	echo"Property Type: {$proptype}<br>";
	echo"Bedrooms: {$bedooms}<br>";
	echo"Bathrooms: {$bathrooms}<br>";
	echo"Amenities: {$amenities}<br>";
	echo"Description: {$description}<br>";
        echo"</td> </tr><tr><td>";
	echo"Found: {$domain_name}";
	echo"</td><td>";

}
	echo"</td> </tr></tbody></table>";
}


?>
 
I have to add this.. The code is complete and you can run it. information is returned from the call and contained in $xml, I would however like to know how I can access the details of the information in $xml and print it all out in the Loop their in the specified format.

PHP Newbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top