DataTable plugin not working with dynamically generated php data? - php

DataTable plugin not working with dynamically generated php data ?
I am using data table in to display a dynamic table. But its not working.
I tried to use static table its working I don't understand the problem
Here is my HTML Table and js script.
Can anyone solve the issue.
$(document).ready(function () {
$('#myTable').dataTable();
});
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" id="myTable">
<thead>
<tr>
<th width="100" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Client Name</th>
<th width="100" height="30"align="left" bordercolor="#999999" bgcolor="#d3d3d3">EPIC ID</th>
<th width="100" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Project Name</th>
<th width="100" height="30"align="left" bordercolor="#999999" bgcolor="#d3d3d3">Category</th>
<th width="100" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Epic Status</th>
<th width="150" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Total Estimated Hours</th>
<th width="150" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3">Total Time Spent</th>
<th width="150" height="30" align="left" bordercolor="#999999" bgcolor="#d3d3d3" >% Hours Burned</th>
<th width="150" height="30" align="left" bordercolor="#000000" bgcolor="#d3d3d3">% Project Complete</th>
<th width="150" height="30" align="left" bordercolor="#000000" bgcolor="#d3d3d3">Action Status</th>
</tr>
</thead>
<tbody>
<tr <?php if($cnt%2==0){echo "bordercolor='#FFFFFF' bgcolor='#FFFFFF'";}else{echo "bordercolor='#999999' bgcolor='#FFFFFF'";}?>>
<td align="left" width="100" height="30"><?php echo "$ClientName";?></td>
<td align="left" width="100" height="30">
<?php
echo form_open('Riskreport',array('name'=>'s2frm'.$cnt,'target'=>'_blank'));?>
<?php echo "$EPICID";?>
<input type="hidden" name="epickeyid" value="<?php echo "$EPICID";?>" />
<?php echo $formbuild;?>
</form>
</td>
<td align="left" width="100" height="30"><?php echo "$ProjectName";?></td>
<td align="left" width="100" height="30"><?php echo "$Category";?></td>
<td align="left" width="100" height="30"><?php echo "$epic_status";?></td>
<td align="left" width="150" height="30"><?php echo "$TotalEstimatedHours";?></td>
<td align="left" width="150" height="30"><?php echo "$TotalTimeSpentinHours";?></td>
<td align="left" width="150" height="30" <?php if(($variance2>0)&&($variance2<=100)){echo "bgcolor='#92d050'";}else if(($variance2>100)&&($variance2<=120)){echo "bgcolor='#FFC200'";}else if($variance2>120){echo "bgcolor='#ff0000'";}else{echo "bgcolor='#FFFFFF'";}?>><?php echo $variance2prcnt;?></td>
<td align="left" width="150" height="30">
<?php
$PrjtCompleteprcnt=$ops1->getprjctdone($EPICID);
echo $PrjtCompleteprcnt;
?>
</td>
<td align="CENTER" width="150" height="30"><?php echo "$ActionStatus";?></td>
</tr>
</tbody>
</table>

Related

Duplicated Results on SQL Query

PHP newbie here! I ve been struggling with this for a few days now and i have decided i cant figure this out on my own.
Basically i have 2 database tables "projects_2016" and "attachment".
I want to show the data of "projects_2016" to show in the top table and then check for a matching id number (and if it exsits) in "attachment" it will list all the results under the "project_2016 data".
At the moment it works great but it duplicates the "projects_2016" data for every "attachment" entry.
Here is my code, any input is appreciated!
PS not too concereded about Sql injections. Still learning that!
<?php include '../../../connection_config.php';
$sql = "SELECT DISTINCT * FROM attachment JOIN projects_2016 ON attachment.attachment_ABE_project_number = projects_2016.id ORDER BY `attachment_ABE_project_number` DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<table width="20" border="1" cellspacing="0" cellpadding="2">
<tr>
<th height="0" scope="col"><table width="990" border="0" align= "center" cellpadding="3" cellspacing="0">
<tr class="text_report">
<td width="107" height="30" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>PNo</strong></td>
<td width="871" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>Project Name</strong></td>
</tr>
<tr>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF" class="text_report"><strong><?php echo "<br>". $row["ID"]. "<br>";?></strong></td>
<td height="20" align="left" valign="middle" bgcolor= "#FFFFFF" class="text_report"><strong><?php echo "<br>". $row["project_name"]. "<br>";?></strong></td>
</tr>
</table>
<?php
$photo_id = $row["ID"];
$contacts = "SELECT DISTINCT * FROM attachment WHERE attachment_ABE_project_number = '$photo_id'" ;
$result_contacts = $conn->query($contacts);
if ($result_contacts->num_rows > 0) {
// output data of each row
while($row_contacts = $result_contacts->fetch_assoc()) {
?>
<table width="990" border="0" align="center" cellpadding= "3" cellspacing="0" class="text_report">
<tr>
<td height="0" colspan="4" align="left" valign="middle" nowrap="nowrap" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td width="319" height="30" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>File Name</strong></td>
<td width="279" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>File Type</strong></td>
<td width="315" align="left" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>File Size (KB)</strong></td>
<td width="53" align="right" valign="middle" nowrap="nowrap" bgcolor="#F5F5F5"><strong>View File</strong></td>
</tr>
<tr>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><?php echo $row_contacts ['file'] ?></td>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><?php echo $row_contacts ['type'] ?></td>
<td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><?php echo $row_contacts ['size'] ?></td>
<td align="right" valign="middle" bgcolor="#FFFFFF">view file</td>
</tr>
<tr>
<td height="0" colspan="4" align="left" valign="middle" bgcolor="#FFFFFF"> </td>
</tr>
<?php
}
?>
</table>
<?php
}
?></th>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<th height="26"> </th>
</tr>
</table>
<p>
<?php
}
}
?>
</p>
</table>
<?php $conn->close();
?>
$sql = "SELECT * FROM projects_2016
WHERE EXISTS (SELECT * FROM attachment WHERE projects_2016.id = attachment_ABE_project_number) ORDER BY id DESC ";

Regex to read Table Rows contents in Array - PHP

Is there any Regex to Read the <td> contents from the following Table, note that there are many similar tables so i want only to read the following table contents.
I want to READ data from 3,4,5 TD from all <TR>
My regex looks like following but doesnt work
$match = preg_replace('~<td width="80" bgcolor="#F3F3E4" align="left"> <a onmouseout="ChangeImage(AE1,1)" onmouseover="ChangeImage(AE1,0)" href="/charts/livegold.html">GOLD</a></td>#[a-z0-9]{6}~i','',$match[3]);
echo '<table><tr>' . $match . '</tr></table>';
the table is as follows
<table width="540" cellspacing="1" cellpadding="0" border="0" align="center">
<tbody><tr>
<td width="16" bgcolor="#000000" align="center"> </td>
<td width="80" bgcolor="#000000" align="center"><font size="1" face="Arial, Helvetica, sans-serif" color="#FFFFFF">www.kitco.com</font></td>
<td width="369" bgcolor="#000000" align="center" colspan="5"><p class="white">The World Spot Price - Asia/Europe/NY markets</p></td>
<td width="73" bgcolor="#000000" align="right"><img width="39" vspace="0" hspace="0" height="17" border="0" alt="light" src="/images/lightgreen.gif"></td>
</tr>
<tr>
<td width="16" bgcolor="#000000" align="center"> </td>
<td width="522" bgcolor="#F3F3E4" align="center" colspan="7"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><font color="GREEN">MARKET IS OPEN</font><br>(Will close in 17 hrs. 41 mins.)<!-- 1486.00--></b></font></td>
</tr>
<tr bgcolor="#F3F3E4">
<td width="16" bgcolor="#000000" align="center"> </td>
<td width="80" bgcolor="#CCCC99" align="center">Metals</td>
<td width="80" bgcolor="#CCCC99" align="center">Date</td>
<td width="80" bgcolor="#CCCC99" align="center">Time (EST)</td>
<td width="68" bgcolor="#CCCC99" align="center">Bid</td>
<td width="68" bgcolor="#CCCC99" align="center">Ask</td>
<td width="146" bgcolor="#CCCC99" align="center" colspan="2">Change from NY Close</td>
</tr>
<tr bgcolor="#F3F3E4">
<td width="16" bgcolor="#000000" align="center"><a onmouseout="ChangeImage('AE1','1')" onmouseover="ChangeImage('AE1','0')" href="/charts/livegold.html"><img width="16" vspace="0" hspace="0" height="13" border="0" alt="Gold Charts" name="AE1" src="http://www.kitco.com/images/graph_down.gif"></a></td>
<td width="80" bgcolor="#F3F3E4" align="left"> <a onmouseout="ChangeImage('AE1','1')" onmouseover="ChangeImage('AE1','0')" href="/charts/livegold.html">GOLD</a></td>
<td width="80" align="center">06/04/2013</td>
<td width="80" align="center">23:34</td>
<td width="68" align="center">1405.50</td>
<td width="68" align="center">1406.50</td>
<td width="73" align="center"><p class="spotgreen">+5.50</p></td>
<td width="73" align="center"><p class="spotgreen">+0.39%</p></td>
</tr>
<tr bgcolor="#F3F3E4">
<td width="16" bgcolor="#000000" align="center"><a onmouseout="ChangeImage('AE2','1')" onmouseover="ChangeImage('AE2','0')" href="/charts/livesilver.html"><img width="16" vspace="0" hspace="0" height="13" border="0" alt="Silver Charts" name="AE2" src="http://www.kitco.com/images/graph_down.gif"></a></td>
<td width="80" align="left"> <a onmouseout="ChangeImage('AE2','1')" onmouseover="ChangeImage('AE2','0')" href="/charts/livesilver.html">SILVER</a></td>
<td width="80" align="center">06/04/2013</td>
<td width="80" align="center">23:34</td>
<td width="68" align="center">22.59</td>
<td width="68" align="center">22.69</td>
<td width="73" align="center"><p class="spotgreen">+0.05</p></td>
<td width="73" align="center"><p class="spotgreen">+0.20%</p></td>
</tr>
<tr bgcolor="#F3F3E4">
<td width="16" bgcolor="#000000" align="center"><a onmouseout="ChangeImage('AE3','1')" onmouseover="ChangeImage('AE3','0')" href="/charts/liveplatinum.html"><img width="16" vspace="0" hspace="0" height="13" border="0" alt="Platinum Charts" name="AE3" src="http://www.kitco.com/images/graph_down.gif"></a></td>
<td width="80" align="left"><p> <a onmouseout="ChangeImage('AE3','1')" onmouseover="ChangeImage('AE3','0')" href="/charts/liveplatinum.html">PLATINUM</a></p></td>
<td width="80" align="center">06/04/2013</td>
<td width="80" align="center">23:34</td>
<td width="68" align="center">1501.00</td>
<td width="68" align="center">1509.00</td>
<td width="73" align="center"><p class="spotgreen">+9.00</p></td>
<td width="73" align="center"><p class="spotgreen">+0.60%</p></td>
</tr>
<tr bgcolor="#F3F3E4">
<td width="16" bgcolor="#000000" align="center"><a onmouseout="ChangeImage('AE4','1')" onmouseover="ChangeImage('AE4','0')" href="/charts/livepalladium.html"><img width="16" vspace="0" hspace="0" height="13" border="0" alt="Palladium Charts" name="AE4" src="http://www.kitco.com/images/graph_down.gif"></a></td>
<td width="80" align="left"> <a onmouseout="ChangeImage('AE4','1')" onmouseover="ChangeImage('AE4','0')" href="/charts/livepalladium.html">PALLADIUM</a></td>
<td width="80" align="center">06/04/2013</td>
<td width="80" align="center">23:25</td>
<td width="68" align="center">755.00</td>
<td width="68" align="center">761.00</td>
<td width="73" align="center"><p class="spotgreen">+6.00</p></td>
<td width="73" align="center"><p class="spotgreen">+0.80%</p></td>
</tr>
</tbody></table>
Here is the data i want to Extract
ok here is the solution with Regex:
$patt = "/<td[^>]*width=['\"]68['\"][^>]*>([0-9\.]+)<\/td>\s*<td[^>]*width=['\"]68['\"][^>]*>([0-9\.]+)<\/td>/i";
if(preg_match_all($patt, $html, $matches))
{
//print all records
//print_r($matches);
for($i=0; $i<count($matches[1]); $i++)
{
echo "Bid: ".$matches[1][$i].", Ask: ".$matches[2][$i]."\n";
}
}
You can use some HTML parser. For PHP there is one http://simplehtmldom.sourceforge.net/
Once the DOM has been loaded into library, get through the TABLE element and iterate through each TR element.

Navigation table not aligning properly in Chrome

On one of my old sites, which has a pretty messy and outdated code, I am having problems with navigation menu in Chrome. It aligns perfectly in Firefox and IE but for some reason in Chrome only first 3 tabs get properly centered.
http://jsfiddle.net/8b2Cm/1/
<table width="765" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="19%"><img src="http://LINK" alt="" width="331" height="95" border="0"></td>
<td width="81%"><img src="http://LINK/images/logo.jpg" alt="" width="434" height="95"></td>
</tr>
</table>
</td>
<td valign="top" class="back1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="1%"><img src="http://LINK/images/left-top.jpg" width="23" height="30" alt=""></td>
<td width="98%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90%" class="left-text11"><div align="center"> Home</div></td>
<td width="10%"><img src="http://LINK/images/line1.jpg" width="8" height="30" alt=""></td>
</tr>
</table></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90%" class="left-text11"><div align="center" class="left-text11">
<? if(!$_SESSION['sbprj_userid'])
{
?><strong>Signup</strong>
<?
}else
{
?>My Account
<?
}
?></div></td>
<td width="10%"><img src="http://LINK/images/line1.jpg" width="8" height="30" alt=""></td>
</tr>
</table></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" width="90%" class="left-text11"><div align="center">Free Poker Money </div></td>
</tr>
</table></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%"><img src="http://LINK/images/line1.jpg" width="8" height="30" alt=""></td>
</tr>
</table></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" width="90%" class="left-text11"><div align="center">Poker School</div></td>
</tr>
</table></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%"><img src="http://LINK/images/line1.jpg" width="8" height="30" alt=""></td>
</tr>
</table></td>
<td class="left-text11"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90%" class="left-text11"><div align="center">News </div></td>
<td width="10%"><img src="http://LINK/images/line1.jpg" width="8" height="30" alt=""></td>
</tr>
</table></td>
<td class="left-text11"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90%" class="left-text11"><div align="center">Support </div></td>
<td width="10%"><img src="http://LINK/images/line1.jpg" width="8" height="30" alt=""></td>
</tr>
</table></td>
<td class="left-text11"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90%" class="left-text11"><div align="center"><img src="http://LINK/images/facebook.png" border="0" width="28" height="25" /> <img src="http://LINK/images/twitter.png" border="0" width="28" height="25" /> <img src="http://LINK/images/googleplus.png" border="0" width="28" height="25" /></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="1%"><img src="http://LINK/images/right-top.jpg" width="24" height="30" alt=""></td>
</tr>
</table></td>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="1%"><img src="http://LINK/images/top-1.jpg" width="23" height="17" alt=""></td>
<td width="98%" class="back2"><img src="http://LINK/images/back2.jpg" width="9" height="17" alt=""></td>
<td width="1%"><img src="http://LINK/images/right-1.jpg" width="24" height="17" alt=""></td>
</tr>
</table></td>
This is the code, any suggestions on how to fix this ?
There is a mess with separators.
Some separators are inside table(horizontal table with tabs, by the way, you should put only that table into fiddle and code, not whole the mess making for us harder to understand) cells, other separators come all alone in separate column, therefore they are taking the same place as column. Check it and move them, like it's done in first two tabs

codeigniter view are not loading in constructor with parameter

I am trying to load a view from constructor with parameter $data. Earlier it was working fine and now suddenly it stopped working. Below is the code:
permissionerror View
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6" align="left" valign="top" background="<?php echo base_url();?>images/bg/topbg.gif"><img src="<?php echo base_url();?>images/bg/top-left.gif" width="5" height="34" /></td>
<td height="34" align="left" valign="middle" background="<?php echo base_url();?>images/bg/topbg.gif" class="heading">Access Forbidden</td>
<td width="6" align="right" valign="top" background="<?php echo base_url();?>images/bg/topbg.gif"><img src="<?php echo base_url();?>images/bg/top-right.gif" width="5" height="34" /></td>
</tr>
<tr>
<td align="left" valign="top" background="<?php echo base_url();?>images/bg/main-content-bg-left.gif"> </td>
<td height="165" valign="top" bgcolor="#FFFFFF" class="leftredheading"><div style="margin:30px auto;padding-left:15px"><? if(isset($sn_error)) echo $sn_error;?></div></td>
<td align="right" valign="top" background="<?php echo base_url();?>images/bg/main-content-bg-right.gif"> </td>
</tr>
<tr>
<td align="left" valign="bottom" background="<?php echo base_url();?>images/bg/bottom-bg.gif"><img src="<?php echo base_url();?>images/bg/bottom-left-corner.gif" width="5" height="5" /></td>
<td valign="top" background="<?php echo base_url();?>images/bg/bottom-bg.gif"></td>
<td align="right" valign="bottom" background="<?php echo base_url();?>images/bg/bottom-bg.gif"><img src="<?php echo base_url();?>images/bg/bottom-right-corner.gif" width="5" height="5" /></td>
</tr>
</table>
Template code:
<?php $this->load->view('includes/login/header'); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#e7e7de">
<tr>
<td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
<td width="191"><img src="<?php echo base_url();?>images/bg/zero.gif" width="191" height="1" /></td>
<td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
<td width="100%"> </td>
<td width="161"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
<td width="191"><img src="<?php echo base_url();?>images/bg/zero.gif" width="191" height="1" /></td>
<td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
</tr>
<tr>
<td> </td>
<td align="left" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"> <?php $this->load->view('includes/login/top_right'); ?> </td>
</tr>
<tr>
<td height="50" background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"> </td>
</tr>
<tr>
<td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"><table width="166" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><img src="<?php echo base_url();?>images/bg/needhelp-top.gif" width="166" height="7" /></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#F8F7EC"> <?php $this->load->view('includes/login/bottom_right'); ?>
<br /></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#F8F7EC"><img src="<?php echo base_url();?>images/bg/needhelp-bottom.gif" width="166" height="7" /></td>
</tr>
</table>
<br /></td>
</tr>
<tr>
<td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"><table width="191" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="6" align="left" valign="top"><img src="<?php echo base_url();?>images/bg/left-bttom.gif" width="6" height="6" /></td>
<td width="100%" background="<?php echo base_url();?>images/bg/leftbottom.gif"></td>
<td height="6" align="right" valign="top"><img src="<?php echo base_url();?>images/bg/right-bttom.gif" width="6" height="6" /></td>
</tr>
</table></td>
</tr>
</table>
<br /></td><td> </td>
<td valign="top" <? if($main_content != 'dashboard' || $main_content == 'publisher_dashboard') { ?> colspan="3" <? } ?>><?php $this->load->view($main_content); ?></td>
<td> </td>
<? if($main_content == 'dashboard' || $main_content == 'publisher_dashboard') { ?>
<td align="right" valign="top"> <?php $this->load->view('includes/login/left'); ?>
</td>
<? } ?>
<td> </td>
</tr>
</table>
<?php $this->load->view('includes/login/footer'); ?>
Here in the above code i am checking whether logged in user is having permission for access then do else part otherwise through the error from if case block.
In IF case it loads the error template.
Please somebody help me to fix the above issue ASAP!
Call parent::__construct(), not parent::Controller().
Edit:
After it was made clear that CodeIgniter 1.7.1 is used and after the view itself was shown, this is your issue:
Your view tries to echo $error instead of $sn_error. If you don't pass $data to the view, then $sn_error (which is checked for) isn't set and that error doesn't occur - that's why the view gets loaded in that case.

PHP Table into array

I´m trying to read a table from a HTML file into an array, I'm stuck.
Any help would be appreciated.
Every table element should be stored into 1 array value
example: $arr[1]= DER HE1 ges 1
PHP
<?php
libxml_use_internal_errors(true);
$i=0;
// new dom object
$dom = new DOMDocument();
//load the html
$html = $dom->loadHTMLFile("106642new.html");
//discard white space
$dom->preserveWhiteSpace = false;
//the table by its tag name
$tables = $dom->getElementsByTagName('table');
//get all rows from the table
$rows = $tables->item(0)->getElementsByTagName('tr');
// $test = $tables->item(0)->getElementsByTagName('td');
// loop over the table rows
foreach ($rows as $row) {
// get each column by tag name
$cols = $row->getElementsByTagName('td');
$i= $i + 1 ;
$value = "Nummer: ".$i.": ".$cols->item(0)->nodeValue.PHP_EOL;
// $value = "test: ".$i.": ".$cols->item(0)->nodeValue.PHP_EOL;
$cols = array(1, 2, 3, 4, 5);
echo $value;
// $cols[$i] = $row;
// echo the values
//echo $cols->item(0)->nodeValue ;
}
?>
HTML:
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<div align=left>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" height="100%">
<tr><td valign="top">&nbsp</td></tr>
<tr><td valign="top">
<p font class="Header">Basisrooster schooljaar 2011 2012 (m.i.v. 12-09-11)</font></p>
<br><div font class="lNameHeader"> </font> </div><table border=1>
<tr class="AccentDark">
<td align="left" width="65" class="tableHeader"></td>
<td align="center" width="auto" class="tableHeader">Maandag</td>
<td align="center" width="auto" class="tableHeader">Dinsdag</td>
<td align="center" width="auto" class="tableHeader">Woensdag</td>
<td align="center" width="auto" class="tableHeader">Donderdag</td>
<td align="center" width="auto" class="tableHeader">Vrijdag</td>
</tr><tr>
<td align="left" width="50" class="tableHeader">1e uur</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell"></td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">WAS</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE09</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">econ</td>
<td align="left" width="9" class="tableCell">5</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">WIK</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC17</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">biol</td>
<td align="left" width="9" class="tableCell">4</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">OTT</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC01</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">dutl</td>
<td align="left" width="9" class="tableCell">6</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell"></td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="50" class="tableHeader">2e uur</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">KEJ</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC02</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">wisA</td>
<td align="left" width="9" class="tableCell">3</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">BRT</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE05</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">netl</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">OTT</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC01</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">dutl</td>
<td align="left" width="9" class="tableCell">6</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">BAU</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HG01</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">lo</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">MET</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HD02</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">entl</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="50" class="tableHeader">3e uur</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">WAS</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE07</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">econ</td>
<td align="left" width="9" class="tableCell">5</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">MET</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HD02</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">entl</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">WAS</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE05</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">econ</td>
<td align="left" width="9" class="tableCell">5</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">BAU</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HG01</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">lo</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">KEJ</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC02</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">wisA</td>
<td align="left" width="9" class="tableCell">3</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="50" class="tableHeader">4e uur</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell"></td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">DER</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE08</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">ges</td>
<td align="left" width="9" class="tableCell">1</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">KEJ</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC06</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">wisA</td>
<td align="left" width="9" class="tableCell">3</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">DER</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE10</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">ges</td>
<td align="left" width="9" class="tableCell">1</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">CHR</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HB15</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">ckv</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="50" class="tableHeader">5e uur</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">DOC</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE09</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">m&o</td>
<td align="left" width="9" class="tableCell">2</td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell"></td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell"></td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">MET</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HD02</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">entl</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">BRT</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HE05</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">netl</td>
<td align="left" width="9" class="tableCell"></td>
</tr>
</table>
</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">OTT</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC03</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">dutl</td>
<td align="left" width="9" class="tableCell">6</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" width="50" class="tableHeader">6e uur</td>
<td align="left" width="auto" class="tableCell"><table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" width="41" class="tableCell">OTT</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="75" class="tableCell">HC03</td>
<td align="left" width="3" class="tableCell">&nbsp</td>
<td align="left" width="73" class="tableCell">dutl</td>
<td align="left" width="9" class="tableCell">6</td>
</tr>
</table>
</td>
If think the problem is that your first table is a container of other tables.
If you want to get the contents of all the tables, than you should also iterate through the tables list.
If you just want to get the contents of a inner table, than first try to locate it in the DOM. I suggest finding the first table, than geting all table elements inside that and iterate through them.
var_dump is a good starting point for debugging, you don't need anything else than you already did, just debug and test more :)
I'm guessing that the fact that it's invalid HTML/XML is screwing you over.
You're using the loadHTMLFile() function which might support malformed HTML up to an extent, but it might also need valid HTML/XML.
If it requires valid XML, then what's probably happening is that the "<br>" doesn't get interpreted as a stand-alone node, but rather as the starting point of a node... meaning that everything after that becomes sub-nodes of "<br>".
Furthermore this line here doesn't make any sense:
<p font class="Header">Basisrooster schooljaar 2011 2012 (m.i.v. 12-09-11)</font></p>
The <font> tag has been obsolete for years and should never be used, but more importantly it's not a font tag but a p-tag, that still also gets closed as if it's a font-tag. Just do:
<p class="Header">Basisrooster schooljaar 2011 2012 (m.i.v. 12-09-11)</p>
So the solution may be that your HTML/XML is invalid.
(Dan Bizdadea also has a good point.)

Categories