Parse json and put into many tables - php

I was trying to print this json in some tables but i can't do it well, i hope you guys can help me, this is the json that i get by AJAX
<?php
$json = array(
'teams'=>array(
array(
'item'=>'tabla_clasif',
'rows'=>array(
array('No'=>'1','logo1'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'2','logo2'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'3','logo3'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'4','logo4'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'5','logo5'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'6','logo6'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'7','logo7'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'8','logo8'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'9','logo9'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'10','logo10'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'11','logo11'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'12','logo12'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'13','logo13'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'14','logo14'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'15','logo15'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12'),
array('No'=>'16','logo16'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','pg'=>'3','pe'=>'0','pp'=>'0','gf'=>'9','gc'=>'2','dg'=>'7','pt'=>'12')
)
),
array(
'item'=>'goles_marca',
'rows'=>array(
array('No'=>'1','logo1'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'2','logo2'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'3','logo3'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'4','logo4'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'5','logo5'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'6','logo6'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'7','logo7'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'8','logo8'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'9','logo9'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'10','logo10'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'11','logo11'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'12','logo12'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'13','logo13'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'14','logo14'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'15','logo15'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3'),
array('No'=>'16','logo16'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gf'=>'3')
)
),
array(
'item'=>'goles_recib',
'rows'=>array(
array('No'=>'1','logo1'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'2','logo2'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'3','logo3'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'4','logo4'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'5','logo5'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'6','logo6'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'7','logo7'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'8','logo8'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'9','logo9'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'10','logo10'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'11','logo11'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'12','logo12'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'13','logo13'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'14','logo14'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'15','logo15'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3'),
array('No'=>'16','logo16'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','gc'=>'3')
)
),
array(
'item'=>'efect_gol',
'rows'=>array(
array('No'=>'1','logo1'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'2','logo2'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'3','logo3'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'4','logo4'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'5','logo5'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'6','logo6'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'7','logo7'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'8','logo8'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'9','logo9'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'10','logo10'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'11','logo11'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'12','logo12'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'13','logo13'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'14','logo14'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'15','logo15'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3'),
array('No'=>'16','logo16'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','eg'=>'3')
)
),
array(
'item'=>'remate_total',
'rows'=>array(
array('No'=>'1','logo1'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'2','logo2'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'3','logo3'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'4','logo4'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'5','logo5'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'6','logo6'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'7','logo7'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'8','logo8'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'9','logo9'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'10','logo10'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'11','logo11'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'12','logo12'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'13','logo13'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'14','logo14'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'15','logo15'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3'),
array('No'=>'16','logo16'=>'images/lobos.png','team1'=>'atlante','pj'=>'3','rt'=>'3')
)
),
)
);
echo json_encode($json);
?>
I need to put them into tables, each table for each item, i have tried with some each until i get every or row but it was really hard
What is the best way to make it?
onSuccess : function(data) {}
A example of the HTML I am looking for would be:
<table>
<thead>
<tr>
<td>No</td>
<td>Logo</td>
<td>Team</td>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><img src="images/lobos.png" /></td>
<td>atlante</td>
</tr>
</tbody>
</table>

Here is another suggestion, using the Element constructor. You should also take a look at MooTools More and the HTML table, probably a good alternative here if you can re-format the JSON a bit.
Anyway, I would do what you are looking for this way:
json = JSON.parse(json);
json.teams.each(function (team) {
var newTable = new Element('table', {
class: 'hidden myWidget'
}).inject(document.body);
var thead = new Element('thead').inject(newTable);
var tittleRow = new Element('tr');
for (var title in team.rows[0]) new Element('td', {
'html': title
}).inject(tittleRow);
tittleRow.inject(thead);
var tbody = new Element('tbody').inject(newTable);
team.rows.each(function (row) {
var newRow = new Element('tr');
for (var value in row) new Element('td', {
'html': row[value]
}).inject(newRow);
newRow.inject(tbody);
});
});
Example: http://jsfiddle.net/2KjSn/
Ps. You should post your answers when you find a solution yourself and not edit the question. This way it might be useful for others also.

Related

Locating TD position by it's TH, domCrawler

I am trying to scrape table's td tag, but first I need to check th. For example let say table structure is like below.
<tbody>
<tr>
<th>color</th>
<td>red</td>
</tr>
<tr>
<th>price</th>
<td>23.267$</td>
</tr>
<tr>
<th>brand</th>
<td>mustang</td>
</tr>
</tbody>
In this table I need to scrape mustang value. But I can't use $crawler->filter('table td')->eq(3); for that. Because position is always changing. So I need to catch the value by it's th. I mean if th's value is brand then get it's td
what is the best way to this?
Not sure it's a best solution, but I solved it with this:
$props = $node->filter("table th")->each(function($th, $i){
return $th->text();
});
$vals = $node->filter("table td")->each(function($td, $i){
return $td->text();
});
$items = [
"brand" => "",
"color" => "",
];
for ($a=0; $a < count($props); $a++) {
switch ($props[$a]) {
case 'brand':
$items["brand"] = $vals[$a];
break;
}
}
If there is another way or much better way to achieve this. Please feel free to post it here. Thank you.

Getting DOM elements of html from file_get_contents [duplicate]

This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 6 years ago.
I am fetching html from a website with file_get_contents. I have a table (with a class name) inside html, and I want to get the data inside html tags.
This is how I fetch the html data from url:
$url = 'http://example.com';
$content = file_get_contents($url);
The html looks like:
<table class="space">
<thead></thead>
<tbody>
<tr>
<td class="marsia">1</td>
<td class="mars">
<div>Mars</div>
</td>
</tr>
<tr>
<td class="earthia">2</td>
<td class="earth">
<div>Earth</div>
</td>
</tr>
</body>
</table>
Is there a way to searh DOM elements in php like we do in jQuery? So that I can access the values 1, 2 (first td) and div's value inside second td.
Something like
a) search the html for table with class name space
b) inside that table, inside tbody, return each tr's 'first td's value' and 'div's value inside second td'
So I get; 1 and Mars, 2 and Earth.
Use the DOM extension, for example. Its DOMXPath class is particularly useful for such kind of tasks.
You can easily set the listed conditions with an XPath expression like this:
//table[#class="space"]//tr[count(td) = 2]/td
where
- //table[#class="space"] selects all table elements from the document having class attribute value equal to "space" string;
- //tr[count(td) = 2] selects all tr elements having exactly two td child elements;
- /td represents the td elements.
Sample implementation:
$html = <<<'HTML'
<table class="space">
<thead></thead>
<tbody>
<tr>
<td class="marsia">1</td>
<td class="mars">
<div>Mars</div>
</td>
</tr>
<tr>
<td class="earthia">2</td>
<td class="earth">
<div>Earth</div>
</td>
</tr>
<tr>
<td class="earthia">3</td>
</tr>
</tbody>
</table>
HTML;
$doc = new DOMDocument;
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$cells = $xpath->query('//table[#class="space"]//tr[count(td) = 2]/td');
$i = 0;
foreach ($cells as $td) {
if (++$i % 2) {
$number = $td->nodeValue;
} else {
$planet = trim($td->textContent);
printf("%d: %s\n", $number, $planet);
}
}
Output
1: Mars
2: Earth
The code above is supposed to be considered as a sample rather than an instruction for practical use, as it is not very scalable. The logic is bound to the fact that the XPath expression selects exactly two cells for each row. In practice, you may want to select the rows, iterate them, and put the extra conditions into the loop, e.g.:
$rows = $xpath->query('//table[#class="space"]//tr');
foreach ($rows as $tr) {
$cells = $xpath->query('.//td', $tr);
if ($cells->length < 2) {
continue;
}
$number = $cells[0]->nodeValue;
$planet = trim($cells[1]->textContent);
printf("%d: %s\n", $number, $planet);
}
DOMXPath::query() is called with an XPath expression relative to the current row ($tr), then checks if the returned DOMNodeList contains at least two cells. The rest of the code is trivial.
You can also use SimpleXML extension, which also supports XPath. But the extension is much less flexible as compared to the DOM extension.
For huge documents, use extensions based on SAX-based parsers such as XMLReader.

Can I loop inside a variable using HTML_Template_Sigma in PHP?

I have to use the HTML_Template_Sigma PEAR Module to do an assignment on PHP that basically wraps all the HTML of a website to make templates with it instead of pasting the same HTML over and over. The thing is that all the content is added using variables and at some point I have to loop through an array inside one of the string variables (which has a table inside). So I checked the documentation which is not really abundant and it does have some sort of loop implementation but oriented to publications and I don't know how to use it to solve my problem.
http://www.pixel2life.com/publish/tutorials/13/pear_module_html_template_sigma/
http://pear.php.net/manual/en/package.html.html-template-sigma.intro-syntax.php
Still what they show is not exactly the same as this.
foreach ($data as $result) {
$plantilla->setCurrentBlock('table_row');
$plantilla->setVariable(array(
'date' => $result[0],
'epicentre' => $result[1],
'region' => $result[2],
'richter' => $result[3],
'mercalli' => $result[4]
));
$plantilla->parseCurrentBlock('table_row');
}
This is my variable:
content = '
<table>
<thead>
<tr>
<th>Date</th>
<th>Epicentre</th>
<th>Region</th>
<th>Mw Richter</th>
<th>Mercalli</th>
</tr>
</thead>
<tbody>
<!-- BEGIN table_row -->
<tr>
<td>{date}</td>
<td>{epicentre}</td>
<td>{region}</td>
<td>{richter}</td>
<td>{mercalli}</td>
</tr>
<!-- END table_row -->
</tbody>
</table>';
My array contains 5 columns of data. I've tried but to no avail.
Thanks in advance!

Delete Rows from HTML Table After x Rows PHP [duplicate]

This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 9 years ago.
Html
<table>
<tr><td></td></tr> //1st row
<tr><td></td></tr> //2nd row
<tr><td></td></tr> //3rd row
<tr><td></td></tr> //4th row
<tr><td></td></tr> //5th row
</table>
What I want to do
if (intval($rows) > 3) {
delete all rows after 3rd row
}
I am using below php code to get html page
$index = substr_count(strtolower(file_get_contents('index.html')), '<tr>');
I hope my question clear enough to understand
Full code
<?php
$htaccess = file_get_contents('index.html');
$new_htaccess = str_replace('<table><tr><td>first row data</td></tr>', '<table><tr><td>first row data</td></tr><tr><td>sec row data</td></tr>', $htaccess);
$pos = strpos($htaccess, $ssa);
if ($pos == false) {
file_put_contents('index.html', $new_htaccess);
} else {
}
$index = substr_count(strtolower(file_get_contents('index.html')), '<tr>');
if (intval($index) > 20) {
//delete end rows and add a new one
}
?>
I would first extract the table using a regex such as \<table>.+<\/table>\, then
strip the <table> </table> tags.
turn the string into array using exlode with <tr> as the delimiter
and finally reconstruct the table using the first 3 items of the array
that is how i would attempt it, not sure it is applicable to your case. obviously you are scraping another site, so it depends a lot of how consistent the code is.
Here is a very simplistic, and untested, method :
//--- create a new DOM document
$doc = new DOMDocument();
//--- load your file
$doc->loadHTMLFile("filename.html");
//--- point to the tables [0] means first table in the file
$tables = $doc->getElementsByTagName('table')[0];
//--- get all the tr within the specified table
$tr = $tables->getElementsByTagName('tr');
//--- loop backwards
for( $x=count($tr)-1; $x>2 $x-- ) {
//--- remove the node (not sure which one will work)
$old = $tr->removeChild($tr[$x]);
$old = $tr->removeChild( $tr->item($x) );
}
//--- save the new file
$doc->saveHTMLFile("/tmp/test.html");
References:
http://www.php.net/manual/en/domdocument.loadhtmlfile.php
http://www.php.net/manual/en/domdocument.getelementsbytagname.php
http://www.php.net/manual/en/domnode.removechild.php
http://www.php.net/manual/en/domdocument.savehtmlfile.php
Hope this is of some help.
jeff posted a good solution, so if you are interested in using any 3rd party libraries.
I suggest you to use ganon.php
<?php
require_once( "ganon.php" );
// Your html
$html = '<table>
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
<tr><td>5</td></tr>
</table>';
// load the html
$html = str_get_dom( $html );
// search for our table
if ( $table = $html( "table", 0 ) ) {
// get all rows which is after 3rd row, here 0 is 1, so 3rd row is 2
if ( $rows = $html( "tr:gt(2)" ) ) {
// loop through rows
foreach( $rows as $row ) {
// .... and delete them
$row->delete();
}
}
}
// output your modified html
echo $html;
?>
Using jquery you can try as following
<script src='http://code.jquery.com/jquery-latest.min.js' type="text/javascript" ></script>
<?php
$html = '<table id="mytable">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
<tr><td>5</td></tr>
</table>';
echo $html;
?>
<script>
$(function() {
var TRs = $("#mytable tr");
for(i=0; i<TRs.length; i++) {
if(i>=3) {
$(TRs[i]).remove();
}
}
});
</script>

How to pull data from xml and break it in pages (pagination)

Hey everyone, I am using simplexml to pull data from an external xml source. I have got values even for limiting the number of results to display. I thought I could paginate with a simple query within the URL, something like "&page=2" but it is not possible as far as documentation shows.
I downloaded a pagination class intended to use within a MYSQL query an tried to used the vars output from the xml. But the output is loading the whole results of the xml and not the specified within the URL vars.
I think what I might do is to count the results first and then paginate, which is what I am trying to do. Do you see anything in this code that can be improved? Sorry If it isn´t clear, but maybe discussing with some coders fellas I can see a bit of light at the end of the tunnel and exaplin a bit better.
So here is the code:
<?
$url ="http://www.somedomain.com/cgi/xml/engine/get_data.php?ref=$ref&checkin=$checkin&checkout=$checkout&rval=$rval&pval=$pval&country=$country&city=$city&lg=$lg&orderby=$orderby&ordertype=$ordertype&maxrows=$maxrows";
// see I am already defining the max num of rows within the url. Which means that the proper way to sort this out is to start counting from the # aheads?
$all = new SimpleXMLElement($url, null, true);
$all->items_total = $hotels->id;
//
require_once 'paginator.class.php';
//calling the paginator class
foreach($all as $hotel) // loop through our hotels
{
$pages = new Paginator;
//creating a new paginator
$pages->mid_range = 7;
$pages->items_total = $hotel->id;
//extracting the var out from the XML
$rest = substr($hotel->description, 0, -150); // returns "abcde"
//echo <<<EOF
<table width="100%" border=0>
<tr>
<td colspan="2">{$hotel->name}<span class="stars" widht="{$hotel->rating}">{$hotel->rating}</span></h2></a><p><b>Direccion:</b> <i>{$hotel->address}</i> - {$hotel->province}</p>
<td colspan="2"><div align="center">PRECIO: {$hotel->currencyCode} {$hotel->minCostOfStay</a>
</div></a></a>
</td>
</tr>
<tr>
<td colspan="2"> $rest...<strong>ampliar información</strong></td>
<td valign="middle"><div align="center"><a href="{$hotel->rooms->room->bookUrl}"><img src="{$hotel->photoUrl}"></div></td>
</tr>
<tr>
<td colspan="2"><div align="center"><strong>VER TODO SOBRE ESTE </strong></div></td>
<td colspan="2"><div align="center">$text</a></div></td>
</a></div></td>
</tr>
//EOF;
echo '</table>';
$pages->paginate();
}
echo $pages->display_pages();
?>
You're clobbering your $all variable:
$all = new SimpleXMLElement($url, null, true); // used by the loop
$all = new Paginator; // reset within the loop

Categories