Forum Moderators: coopster
<?php
echo ('<table class="tablea">');
$q=$_GET["q"];$xmlDoc = new DOMDocument();
$xmlDoc->load("book.xml");
$x=$xmlDoc->getElementsByTagName('title');
for ($i=0; $i<=$x->length-1; $i++)
{
//Process only element nodes
if ($x->item($i)->nodeType==1)
{
if ($x->item($i)->childNodes->item(0)->nodeValue == $q)
{
$y=($x->item($i)->parentNode);
}
}
}
$cd=($y->childNodes);for ($i=0;$i<$cd->length;$i++)
{
echo($i);
//Process only element nodes
if ($cd->item($i)->nodeType==1)
{
if($i==7)
echo ('</table><br /><table class="tableb">');
echo('<tr><td>');if($i%10==7 and $i>7)
{
echo("</table><br /><table class='tableb'>");
if($i%10==8 and $i>7)
echo("</table><br /><table class='tableb'>");
echo('<tr><td>');
}
echo($cd->item($i)->childNodes->item(0)->nodeValue);
}
}
echo ('</table>');
?>
It's also worth mentioning that as you can see I echo'd the value of $i onto my page so that I could temporarily easily count the results, strangely, it doesn't start the count at the first value of the first cell in the first table, it counts '0' then '1' ABOVE the first table then continues the count at '2' in the first cell of the first table?!