I have a code that reads an HTML file from my local web server localhost and then converts it to XHTML with tidy. Then i load that XHTML into my DOM. the code looks like this
<?php
function getXHTML($html)
{
$options = array("output-html" => true,"quote-nbsp" => true, "drop-proprietary-attributes" => true,"drop-font-tags" => true,"drop-empty-paras" => true,"hide-comments" => true);
$tidy=new tidy();
$xhtml=$tidy->repairString($html,$options);
echo $xhtml;
return $xhtml;
}
$content = file_get_contents("http://localhost/filename.htm");
$page = new DOMDocument();
$xpath=new DOMXPath($page);
$content = getXHTML($content); // this is a tidy function to return XHTML
$page->loadHTML($content);
$totalPath = "//body/table[3]/tbody/tr[1]/td[4]";
$total = $xpath->query($totalPath);
echo $total->length; // this shows zero
?>
the contents of filename.htm looks like this
<!-- saved from url=(0041)http://www.rtu.ac.in/results/reformat.php -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="SHORTCUT ICON" href="http://www.rtu.ac.in/favicon.ico">
<link href="./Result - Rajasthan Technical University6_files/styleresults.css" rel="stylesheet" type="text/css">
<title>Result - Rajasthan Technical University</title>
</head>
<body>
<table width="773" cellpadding="5" cellspacing="0" align="center">
<tbody><tr height="60">
<td width="16%" height="60" valign="top"><font color="brown" size="+2"><img src="./Result - Rajasthan Technical University6_files/logo.jpg" width="100" height="102" border="0" align="right"> </font></td>
<td width="72%" height="60" align="center" valign="top"><p><font color="brown" size="+2"><strong>RAJASTHAN TECHNICAL UNIVERSITY </strong></font></p><font color="brown" size="+2">
<p><font size="+1"><strong>B.Tech -IVth SEMESTER -2010(Main) 16.5.2011</strong></font></p><font size="+1"> </font></font></td>
<td width="12%" height="80"><strong>www.rtu.ac.in</strong> </td>
</tr>
</tbody></table>
<br>
<br>
<table width="783" align="center" cellpadding="5" cellspacing="0" class="table">
<tbody>
<tr>
<td width="34%" align="center" valign="top" rowspan="2"><strong>Subject(s) Name </strong> </td>
<td width="10%" align="center" valign="top" colspan="1" rowspan="2"> <strong>Subject(s) Code </strong> </td>
<td align="center" valign="top" colspan="3" rowspan="1"><strong>Marks Obtained </strong> </td>
</tr>
<tr>
<td width="20%" align="center"><strong>Internal</strong> </td>
<td width="18%" align="center"><strong>Theory</strong> </td>
<td width="18%" align="center"> </td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>SUBJECT-1</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4551</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> 16</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 50</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> </td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>SUBJECT-2</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;"> 4552</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> 17</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 61</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> </td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>SUBJECT-3</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4553</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> 19</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 49</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> </td>
</tr>
<tr>
<td align="center" style=" border-bottom: 0px none transparent;"><strong>SUBJECT-4</strong> </td>
<td align="center" style=" border-bottom: 0px none transparent;">4554</td>
<td align="center" style=" border-bottom: 0px none transparent;"> 14</td>
<td align="center" style=" border-bottom: 0px none transparent;"> 68</td>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
</tr>
<tr>
<td align="center" style=" border-bottom: 0px none transparent;"><strong>SUBJECT-5</strong> </td>
<td align="center" style=" border-bottom: 0px none transparent;">4555</td>
<td align="center" style=" border-bottom: 0px none transparent;"> 14</td>
<td align="center" style=" border-bottom: 0px none transparent;"> 36</td>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>SUBJECT-6</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4556</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> 19</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 48</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> </td>
</tr><tr>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
<td align="center" style=" border-bottom: 0px none transparent;"> <strong>Internal</strong> </td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"><strong>Practical</strong> </td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>PSUBJECT-1</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4174</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> </td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 29</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;">48</td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>PSUBJECT-2</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4175</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> </td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 16</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;">26</td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>PSUBJECT-3</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4171</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> </td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> 15</td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;">27</td>
</tr>
<tr>
<td align="center" style=" border-bottom: 0px none transparent;"><strong>PSUBJECT-4</strong> </td>
<td align="center" style=" border-bottom: 0px none transparent;">4172</td>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
<td align="center" style=" border-bottom: 0px none transparent;"> 17</td>
<td align="center" style=" border-bottom: 0px none transparent;">29</td>
</tr>
<tr>
<td align="center" style=" border-bottom: 0px none transparent;"><strong>PSUBJECT-5</strong> </td>
<td align="center" style=" border-bottom: 0px none transparent;">4173</td>
<td align="center" style=" border-bottom: 0px none transparent;"> </td>
<td align="center" style=" border-bottom: 0px none transparent;"> 29</td>
<td align="center" style=" border-bottom: 0px none transparent;">46</td>
</tr>
<tr>
<td width="34%" align="center" style=" border-bottom: 0px none transparent;"><strong>Disipline (Deca)</strong> </td>
<td width="10%" align="center" style=" border-bottom: 0px none transparent;">4176</td>
<td width="20%" align="center" style=" border-bottom: 0px none transparent;"> </td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;"> </td>
<td width="18%" align="center" style=" border-bottom: 0px none transparent;">46</td>
</tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> </td></tr></tbody>
</table>
<br><table width="783" align="center" cellpadding="5" cellspacing="0" class="table">
<tbody><tr>
<td width="18%" align="center" valign="top"><strong>Practical Marks </strong> </td>
<td width="18%" align="center" valign="top">328</td>
<td width="19%" align="center" valign="top"><strong>Theory Marks </strong> </td>
<td width="19%" align="center" valign="top">411</td>
</tr>
<tr>
<td width="18%" align="center"><strong>Institute Code </strong> </td>
<td width="18%" align="center"> 1229 </td>
<td width="19%" align="center"><strong>DECCA </strong> </td>
<td width="19%" align="center">4176</td>
</tr>
<tr>
<td width="18%" align="center"><strong>Division </strong> </td>
<td width="18%" align="center"> PASS </td>
<td width="19%" align="center"><strong>Grand Total </strong> </td>
<td width="19%" align="center">739</td>
</tr>
</tbody></table>
<!-- Reformatter by Shashank Kumar Jain (CS, IIIrd Year, 2010-11) -->
<div id="csscan-wrapper" style="display: none; "><h2 id="csscan-header">element</h2><table id="csscan-table"><tbody><tr><th colspan="2" id="csscan-header-font" class="csscan-header">Font</th></tr><tr id="csscan-row-font-family"><td id="csscan-property-font-family" class="csscan-property">font-family</td><td id="csscan-value-font-family" class="csscan-value"></td></tr><tr id="csscan-row-font-size"><td id="csscan-property-font-size" class="csscan-property">font-size</td><td id="csscan-value-font-size" class="csscan-value"></td></tr><tr id="csscan-row-font-style"><td id="csscan-property-font-style" class="csscan-property">font-style</td><td id="csscan-value-font-style" class="csscan-value"></td></tr><tr id="csscan-row-font-variant"><td id="csscan-property-font-variant" class="csscan-property">font-variant</td><td id="csscan-value-font-variant" class="csscan-value"></td></tr><tr id="csscan-row-font-weight"><td id="csscan-property-font-weight" class="csscan-property">font-weight</td><td id="csscan-value-font-weight" class="csscan-value"></td></tr><tr id="csscan-row-letter-spacing"><td id="csscan-property-letter-spacing" class="csscan-property">letter-spacing</td><td id="csscan-value-letter-spacing" class="csscan-value"></td></tr><tr id="csscan-row-line-height"><td id="csscan-property-line-height" class="csscan-property">line-height</td><td id="csscan-value-line-height" class="csscan-value"></td></tr><tr id="csscan-row-text-decoration"><td id="csscan-property-text-decoration" class="csscan-property">text-decoration</td><td id="csscan-value-text-decoration" class="csscan-value"></td></tr><tr id="csscan-row-text-align"><td id="csscan-property-text-align" class="csscan-property">text-align</td><td id="csscan-value-text-align" class="csscan-value"></td></tr><tr id="csscan-row-text-indent"><td id="csscan-property-text-indent" class="csscan-property">text-indent</td><td id="csscan-value-text-indent" class="csscan-value"></td></tr><tr id="csscan-row-text-transform"><td id="csscan-property-text-transform" class="csscan-property">text-transform</td><td id="csscan-value-text-transform" class="csscan-value"></td></tr><tr id="csscan-row-white-space"><td id="csscan-property-white-space" class="csscan-property">white-space</td><td id="csscan-value-white-space" class="csscan-value"></td></tr><tr id="csscan-row-word-spacing"><td id="csscan-property-word-spacing" class="csscan-property">word-spacing</td><td id="csscan-value-word-spacing" class="csscan-value"></td></tr><tr id="csscan-row-color"><td id="csscan-property-color" class="csscan-property">color</td><td id="csscan-value-color" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-background" class="csscan-header">Background</th></tr><tr id="csscan-row-background-attachment"><td id="csscan-property-background-attachment" class="csscan-property">bg-attachment</td><td id="csscan-value-background-attachment" class="csscan-value"></td></tr><tr id="csscan-row-background-color"><td id="csscan-property-background-color" class="csscan-property">bg-color</td><td id="csscan-value-background-color" class="csscan-value"></td></tr><tr id="csscan-row-background-image"><td id="csscan-property-background-image" class="csscan-property">bg-image</td><td id="csscan-value-background-image" class="csscan-value"></td></tr><tr id="csscan-row-background-position"><td id="csscan-property-background-position" class="csscan-property">bg-position</td><td id="csscan-value-background-position" class="csscan-value"></td></tr><tr id="csscan-row-background-repeat"><td id="csscan-property-background-repeat" class="csscan-property">bg-repeat</td><td id="csscan-value-background-repeat" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-size" class="csscan-header">Box</th></tr><tr id="csscan-row-width"><td id="csscan-property-width" class="csscan-property">width</td><td id="csscan-value-width" class="csscan-value"></td></tr><tr id="csscan-row-height"><td id="csscan-property-height" class="csscan-property">height</td><td id="csscan-value-height" class="csscan-value"></td></tr><tr id="csscan-row-border-top"><td id="csscan-property-border-top" class="csscan-property">border-top</td><td id="csscan-value-border-top" class="csscan-value"></td></tr><tr id="csscan-row-border-right"><td id="csscan-property-border-right" class="csscan-property">border-right</td><td id="csscan-value-border-right" class="csscan-value"></td></tr><tr id="csscan-row-border-bottom"><td id="csscan-property-border-bottom" class="csscan-property">border-bottom</td><td id="csscan-value-border-bottom" class="csscan-value"></td></tr><tr id="csscan-row-border-left"><td id="csscan-property-border-left" class="csscan-property">border-left</td><td id="csscan-value-border-left" class="csscan-value"></td></tr><tr id="csscan-row-margin"><td id="csscan-property-margin" class="csscan-property">margin</td><td id="csscan-value-margin" class="csscan-value"></td></tr><tr id="csscan-row-padding"><td id="csscan-property-padding" class="csscan-property">padding</td><td id="csscan-value-padding" class="csscan-value"></td></tr><tr id="csscan-row-max-height"><td id="csscan-property-max-height" class="csscan-property">max-height</td><td id="csscan-value-max-height" class="csscan-value"></td></tr><tr id="csscan-row-min-height"><td id="csscan-property-min-height" class="csscan-property">min-height</td><td id="csscan-value-min-height" class="csscan-value"></td></tr><tr id="csscan-row-max-width"><td id="csscan-property-max-width" class="csscan-property">max-width</td><td id="csscan-value-max-width" class="csscan-value"></td></tr><tr id="csscan-row-min-width"><td id="csscan-property-min-width" class="csscan-property">min-width</td><td id="csscan-value-min-width" class="csscan-value"></td></tr><tr id="csscan-row-outline-color"><td id="csscan-property-outline-color" class="csscan-property">outline-color</td><td id="csscan-value-outline-color" class="csscan-value"></td></tr><tr id="csscan-row-outline-style"><td id="csscan-property-outline-style" class="csscan-property">outline-style</td><td id="csscan-value-outline-style" class="csscan-value"></td></tr><tr id="csscan-row-outline-width"><td id="csscan-property-outline-width" class="csscan-property">outline-width</td><td id="csscan-value-outline-width" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-position" class="csscan-header">Positioning</th></tr><tr id="csscan-row-position"><td id="csscan-property-position" class="csscan-property">position</td><td id="csscan-value-position" class="csscan-value"></td></tr><tr id="csscan-row-top"><td id="csscan-property-top" class="csscan-property">top</td><td id="csscan-value-top" class="csscan-value"></td></tr><tr id="csscan-row-bottom"><td id="csscan-property-bottom" class="csscan-property">bottom</td><td id="csscan-value-bottom" class="csscan-value"></td></tr><tr id="csscan-row-right"><td id="csscan-property-right" class="csscan-property">right</td><td id="csscan-value-right" class="csscan-value"></td></tr><tr id="csscan-row-left"><td id="csscan-property-left" class="csscan-property">left</td><td id="csscan-value-left" class="csscan-value"></td></tr><tr id="csscan-row-float"><td id="csscan-property-float" class="csscan-property">float</td><td id="csscan-value-float" class="csscan-value"></td></tr><tr id="csscan-row-display"><td id="csscan-property-display" class="csscan-property">display</td><td id="csscan-value-display" class="csscan-value"></td></tr><tr id="csscan-row-clear"><td id="csscan-property-clear" class="csscan-property">clear</td><td id="csscan-value-clear" class="csscan-value"></td></tr><tr id="csscan-row-z-index"><td id="csscan-property-z-index" class="csscan-property">z-index</td><td id="csscan-value-z-index" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-list" class="csscan-header">List</th></tr><tr id="csscan-row-list-style-image"><td id="csscan-property-list-style-image" class="csscan-property">list-style-image</td><td id="csscan-value-list-style-image" class="csscan-value"></td></tr><tr id="csscan-row-list-style-type"><td id="csscan-property-list-style-type" class="csscan-property">list-style-type</td><td id="csscan-value-list-style-type" class="csscan-value"></td></tr><tr id="csscan-row-list-style-position"><td id="csscan-property-list-style-position" class="csscan-property">list-style-position</td><td id="csscan-value-list-style-position" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-table" class="csscan-header">Table</th></tr><tr id="csscan-row-vertical-align"><td id="csscan-property-vertical-align" class="csscan-property">vertical-align</td><td id="csscan-value-vertical-align" class="csscan-value"></td></tr><tr id="csscan-row-border-collapse"><td id="csscan-property-border-collapse" class="csscan-property">border-collapse</td><td id="csscan-value-border-collapse" class="csscan-value"></td></tr><tr id="csscan-row-border-spacing"><td id="csscan-property-border-spacing" class="csscan-property">border-spacing</td><td id="csscan-value-border-spacing" class="csscan-value"></td></tr><tr id="csscan-row-caption-side"><td id="csscan-property-caption-side" class="csscan-property">caption-side</td><td id="csscan-value-caption-side" class="csscan-value"></td></tr><tr id="csscan-row-empty-cells"><td id="csscan-property-empty-cells" class="csscan-property">empty-cells</td><td id="csscan-value-empty-cells" class="csscan-value"></td></tr><tr id="csscan-row-table-layout"><td id="csscan-property-table-layout" class="csscan-property">table-layout</td><td id="csscan-value-table-layout" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-effects" class="csscan-header">Effects</th></tr><tr id="csscan-row-text-shadow"><td id="csscan-property-text-shadow" class="csscan-property">text-shadow</td><td id="csscan-value-text-shadow" class="csscan-value"></td></tr><tr id="csscan-row--webkit-box-shadow"><td id="csscan-property--webkit-box-shadow" class="csscan-property">-webkit-box-shadow</td><td id="csscan-value--webkit-box-shadow" class="csscan-value"></td></tr><tr id="csscan-row-border-radius"><td id="csscan-property-border-radius" class="csscan-property">border-radius</td><td id="csscan-value-border-radius" class="csscan-value"></td></tr><tr><th colspan="2" id="csscan-header-other" class="csscan-header">Other</th></tr><tr id="csscan-row-overflow"><td id="csscan-property-overflow" class="csscan-property">overflow</td><td id="csscan-value-overflow" class="csscan-value"></td></tr><tr id="csscan-row-cursor"><td id="csscan-property-cursor" class="csscan-property">cursor</td><td id="csscan-value-cursor" class="csscan-value"></td></tr><tr id="csscan-row-visibility"><td id="csscan-property-visibility" class="csscan-property">visibility</td><td id="csscan-value-visibility" class="csscan-value"></td></tr></tbody></table></div></body></html>
the XPath above is correct as i have checked it with FirePath. can anyone tell me what i am doing wrong?
Try to use loadHTML($string) instead of loadXML. From manual:
The function parses the HTML contained in the string source. Unlike loading XML, HTML does not have to be well-formed to load.
Update 1
loadHTML creates the same DOM tree in memory as loadXML does. It only uses less strict parser. Here is example code with XPath:
<?php
$content = file_get_contents("1.html");
$page = new DOMDocument();
$page->loadHTML($content); // this will ignore most errors in formating
echo $page->saveHTML();
echo "=====\n";
$xpath = new DOMXPath($page); // use any "XML" parsing function
foreach ($xpath->query("//li[not(#id='3')]") as $elem) {
echo "[".trim($elem->textContent)."]\n";
}
Content of 1.html file is:
<li id="1">item 1
<li id="2">item 2
<li id="3">item 3
<li id="4">item 4
Output will be:
<!DOCTYPE html PUBLIC "...">
<html><body>
<li id="1">item 1
</li>
<li id="2">item 2
</li>
<li id="3">item 3
</li>
<li id="4">item 4
</li>
</body></html>
=====
[item 1]
[item 2]
[item 4]
Update 2
You just missed initializing for $xpath variable. I've also removed getXHTML call, because it's not necessary:
$content = file_get_contents("2.html");
$page = new DOMDocument();
//$content=getXHTML($content); // no need this if you're using loadHTML
$page->loadHTML($content);
$totalPath = "//body/table[3]/tbody/tr[1]/td[4]";
$xpath = new DOMXPath($page); // creating $xpath object
$total = $xpath->query($totalPath);
echo "[",$total->length,"]";
How much have you played with the PHP Tidy options? If the error you get refers to entities (specifically ) I wonder if setting numeric-entities "on" or playing with the value for preserve-entities would help.
Plan B: Try this. XPath worked even with poorly formed html files.
<?php
$oldSetting = libxml_use_internal_errors( true );
libxml_clear_errors();
$html = new DOMDocument();
$html->loadHtmlFile(
'myHtmlFile.html');
$xpath = new DOMXPath( $html );
$test = $xpath->query( "//div[#id='mydiv']" );
$div = $test->item(0);
echo $div->getAttribute('style');
libxml_clear_errors();
libxml_use_internal_errors( $oldSetting );
?>
the answer to the above question somewhat tricky. my original code looked something like
$xpath=new DOMXPath($page);
..
...
...
$page->loadHTML($content);
..
...
$totalPath = "//body/table[3]/tbody/tr[1]/td[4]";
$total = $xpath->query($totalPath);
...
...
what happens above is that $xpath is created on an empty document because the html is still not loaded in the Dom. so when xpath ran any query it ran the query on an empty document.
now i changed the order of the 2 statements
...
...
$page->loadHTML($content);
$xpath=new DOMXPath($page);
...
...
$totalPath = "//body/table[3]/tbody/tr[1]/td[4]";
$total = $xpath->query($totalPath);
now it works because $xpath is created on a nonempty document
Related
So my problem can be seen in this picture:
How do I make every cell have the text at the same height? The last <th> (text+img) drags it down for some reason.
My css:
.table {
width: 100%;
padding: 0;
margin: 15px 0 0;
border-collapse: collapse
}
.table th {
text-align: left;
color: #fff;
background: 0 0;
text-transform: uppercase;
font-size: .9em;
line-height: 1em;
padding: .5em;
}
.table th.gold {
color: #ffdd45
}
.table td {
padding: .7em .5em .6em;
font-size: 1.1em;
line-height: 1.2em;
background: #222;
border: 2px solid rgba(0, 0, 0, 0);
vertical-align: middle;
}
<table class="table rate" style="margin-top: 0;">
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Number 1</th>
<th class="gold">Number 2</th>
<th>text+img</th>
</tr>
</thead>
<tbody id="players-table1">
<tr>
<td style="text-align: center;">1</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user0</span></a>
</td>
<td>4</td>
<td class="bold gold">500</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:10%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user</span></a>
</td>
<td>4</td>
<td class="bold gold">400</td>
<td style="width:10%"><i>35x<img src="piclink" style="width:55%;height:10%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="piclink" style="width:55%;height:10%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="piclink"/></i></td>
</tr>
</tbody>
</table>
There are 2 ways to fix this:
Decreasing the height of the image(which is what I did in answer), this was 10% before and I made it as 5%. The td content was pushing down due to that.
If you don't want to decrease the height of the image then you have to increase the height of the each row so that the height can easily fit-in.
so call is yours what to choose.
.table {
width: 100%;
padding: 0;
margin: 15px 0 0;
border-collapse: collapse
}
.table th {
text-align: left;
color: #fff;
background: 0 0;
text-transform: uppercase;
font-size: .9em;
line-height: 1em;
padding: .5em;
}
.table th.gold {
color: #ffdd45
}
.table td {
padding: .7em .5em .6em;
font-size: 1.1em;
line-height: 1.2em;
background: #222;
border: 2px solid rgba(0, 0, 0, 0);
vertical-align: middle;
border: 1px solid red;
}
<table class="table rate" style="margin-top: 0;">
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Number 1</th>
<th class="gold">Number 2</th>
<th>text+img</th>
</tr>
</thead>
<tbody id="players-table1">
<tr>
<td style="text-align: center;">1</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user0</span></a>
</td>
<td>4</td>
<td class="bold gold">500</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user</span></a>
</td>
<td>4</td>
<td class="bold gold">400</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>
<a href="/user/9842394892389" class="username">
<img src="piclink" alt="Аvatar"><span>user2</span></a>
</td>
<td>3</td>
<td class="bold gold">300</td>
<td style="width:10%"><i>35x<img src="http://placekitten.com/301/301" style="width:55%;height:5%"/></i></td>
</tr>
</tbody>
</table>
I'm working on making an email PHP that sends me an email whenever someone completes my survey. I have all of these variables defined in my code and every single one of them works correctly and shows up in my email except the $phone variable. In that row of my code, I get a blank line. Why would that be?
<?PHP
/* message */
$name = $_POST['name'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$fulladdress = $address . ", " . $address2;
$city = $_POST['city'];
$state = $_POST['state'];
$zipcode = $_POST['zipcode'];
$city_state_zip = $city . ", " . $state . " " . $zipcode;
$email = $_POST['email'];
$phone = $_POST['phone'];
$phone = "(" . substr($phone, 0, 3). ") " . substr($phone, 3, 3) . "-" . substr($phone,6,4);
$years_experience = $_POST['years_experience'];
$education_level = $_POST['education_level'];
$salary = $_POST['salary'];
$current_employer = $_POST['current_employer'];
$previous_employer1 = $_POST['previous_employer1'];
$previous_employer2 = $_POST['previous_employer2'];
if( empty($previous_employer2) AND empty($previous_employer1) ) {
$previous_employers = "None";
}
elseif(empty($previous_employer2)) {
$previous_employers = $previous_employer1;
}
else{
$previous_employers = $previous_employer1 . " and " . $previous_employer2;
}
$grad_year = $_POST['grad_year'];
$class_size = $_POST['class_size'];
$department_feedback = $_POST['department_feedback'];
$wishes = $_POST['wishes'];
/* $size = count($useful_classes);
$classes="";
foreach ($useful_classes as $key => $value){
$classes .= $value;
if($size > ($key + 1)){
$classes .= ", ";
}
}
$size2 = count($skills);
$skillsets="";
foreach ($skills as $key => $value){
$skillsets .= $value;
if($size2 > ($key + 1)){
$skillsets .= ", ";
}
} */
$restaurant = $_POST['restaurant'];
$hobbies = $_POST['hobbies'];
$kstate_memory = $_POST['kstate_memory'];
$messageTT ="";
$messageTT .= <<<EOT
<html>
<head>
<title></title>
</head>
<body>
<table style="border-collapse: collapse">
<tr>
<td align="right" style="border: solid 1px black"> <b>Name:</b> </td>
<td align="left" style="border: solid 1px black"> $name </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Address:</b> </td>
<td align="left" style="border: solid 1px black"> $fulladdress </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> </td>
<td align="left" style="border: solid 1px black"> $city_state_zip </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Email:</b> </td>
<td align="left" style="border: solid 1px black"> $email </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Phone:</b> </td>
<td align="left" style="border: solid 1px black" $phone </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Years of Professional Experience:</b> </td>
<td align="left" style="border: solid 1px black"> $years_experience </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Education Level:</b> </td>
<td align="left" style="border: solid 1px black"> $education_level </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Salary Ranking:</b> </td>
<td align="left" style="border: solid 1px black"> $salary </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Current Employer:</b> </td>
<td align="left" style="border: solid 1px black"> $current_employer </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b> Past Employer(s): </b></td>
<td align="left" style="border: solid 1px black"> $previous_employers </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Graduation Year: </b> </td>
<td align="left" style="border: solid 1px black"> $grad_year </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Most Useful Classes:</b> </td>
<td align="left" style="border: solid 1px black"> $classes </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Most Useful Skills: </b> </td>
<td align="left" style="border: solid 1px black"> $skillsets </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Class Size: </b> </td>
<td align="left" style="border: solid 1px black"> $class_size </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b> Department Feedback: </b></td>
<td align="left" style="border: solid 1px black"> $department_feedback </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b> Wishes for Next Generation: </b></td>
<td align="left" style="border: solid 1px black"> $wishes </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Favorite Restaurant: </b> </td>
<td align="left" style="border: solid 1px black"> $restaurant </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>What You Do for Fun: </b> </td>
<td align="left" style="border: solid 1px black"> $hobbies </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Favorite K-State Memory: </b> </td>
<td align="left" style="border: solid 1px black"> $kstate_memory </td>
</tr>
</table>
</body>
</html>
EOT;
/* recipients */
$to = "anon <anon#anon.edu>";
/* subject */
$subject = " Survey Form Submission -- " . $_POST['name'];;
//$headers = 'From: '.$_POST['email']."\n";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
/* additional headers */
$headers .= 'From: '.$_POST['name'].' <'.$_POST['email'].">\n";
//Next two lines for cc and bcc....
//$headers .= "Cc: birthdayarchive#example.com\r\n";
//$headers .= "Bcc: birthdaycheck#example.com\r\n";
/* and now mail it */
mail($to, $subject, $messageTT, $headers);
?>
In your line
<td align="left" style="border: solid 1px black" $phone </td>
you are missing an HTML closing tag.
It should read
<td align="left" style="border: solid 1px black"> $phone </td> instead.
Please also take the other statements concerning security serious. This risk is often underrated.
This is the thank you page I am trying to have someones name be displayed like "Thank you John, ..."
But i can't seem to have it post the name. my $first_name is in another php file
<?php include("email.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<base target="_blank">
<title>Mid-Night Designs</title>
<style type="text/css">
body *{font-family: 'Open Sans', Arial, sans-serif !important}
div, p, a, li, td { -webkit-text-size-adjust:none; }
*{-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
td{word-break: break-word;}
a{word-break: break-word; text-decoration: none; color: inherit;}
body .ReadMsgBody
{width: 100%; background-color: #ffffff;}
body .ExternalClass
{width: 100%; background-color: #ffffff;}
body{width: 100%; height: 100%; background-color: #ffffff; margin:0; padding:0; -webkit-font-smoothing: antialiased;}
html{ background-color:#ffffff; width: 100%;}
body p {padding: 0!important; margin-top: 0!important; margin-right: 0!important; margin-bottom: 0!important; margin-left: 0!important; }
body img {user-drag: none; -moz-user-select: none; -webkit-user-drag: none;}
body a.rotator img {-webkit-transition: all 1s ease-in-out;-moz-transition: all 1s ease-in-out; -o-transition: all 1s ease-in-out; -ms-transition: all 1s ease-in-out; }
body a.rotator img:hover {-webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -o-transform: rotate(360deg);-ms-transform: rotate(360deg); }
body .hover:hover {opacity:0.85;filter:alpha(opacity=85);}
body .jump:hover {opacity:0.75; filter:alpha(opacity=75); padding-top: 10px!important;}
body .logo img {width: 150px; height: auto;}
body .icon25 img {width: 25px; height: auto;}
body .icon18 img {width: 18px; height: auto;}
</style>
<style type="text/css">#media only screen and (max-width: 640px){
body body{width:auto!important;}
body table[class=full] {width: 100%!important; clear: both; }
body table[class=mobile] {width: 100%!important; padding-left: 30px; padding-right: 30px; clear: both; }
body table[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
body td[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
body .erase {display: none;}
body .buttonScale {float: none!important; text-align: center!important; display: inline-block!important; clear: both;}
body td[class=pad20] {padding-left: 20px!important; padding-right: 20px!important; text-align: center!important; clear: both; }
}</style>
<style type="text/css">#media only screen and (max-width: 479px){
body body{width:auto!important;}
body table[class=full] {width: 100%!important; clear: both; }
body table[class=mobile] {width: 100%!important; padding-left: 20px; padding-right: 20px; clear: both; }
body table[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
body td[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
body .erase {display: none;}
body .buttonScale {float: none!important; text-align: center!important; display: inline-block!important; clear: both;}
body td[class=pad20] {padding-left: 20px!important; padding-right: 20px!important; text-align: center!important; clear: both; }
}</style>
</head>
<body style='margin: 0; padding: 0;'>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
<tbody><tr>
<td align="center">
<table class="full" align="center" border="0" width="100%" cellpadding="0" cellspacing="0">
<tbody><tr>
<td align="center" class="pad20">
<table width="500" border="0" cellpadding="0" cellspacing="0" align="center" class="full">
<tbody><tr>
<td width="100%" height="15" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td valign="middle" width="100%" style="font-family: Helvetica, Arial, sans-serif, 'Open Sans'; color: #929292; font-weight: 400; font-size: 12px; line-height: 20px; text-align: center;">
<br>
</td>
</tr>
<tr>
<td width="100%" height="40" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td valign="middle" align="center" width="100%" class="logo" style="line-height: 1px; text-align: center;"></td>
</tr>
<tr>
<td width="100%" height="30" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</table><table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
<tbody><tr>
<td align="center" class="pad20">
<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff; border-top-left-radius: 5px; border-top-right-radius: 5px;">
<tbody><tr>
<td width="100%" height="30" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
<tbody><tr>
<td align="center" class="pad20">
<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff;">
<tbody><tr>
<td align="center" class="pad20">
<table width="450" border="0" cellpadding="0" cellspacing="0" align="center" class="full">
<tbody><tr>
<td width="100%" height="10" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td valign="middle" width="100%" style="font-family: Helvetica, Arial, sans-serif, 'Open Sans'; color: #111111; font-weight: 800; font-size: 30px; line-height: 36px; text-align: center; text-transform: uppercase;">
Thank you!
</td>
</tr>
<tr>
<td width="100%" height="20" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td width="100%" style="color: #929292; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 14px; text-align: center; line-height: 22px;" class="fullCenter">
<span style="color:#000000;"><span style="font-size:14px;"><strong>Thank you<?php echo $_POST['first_name'];?>
, for using our quote calculator. If you have any further questions feel free to contact us!</strong></span></span>
</td>
</tr>
<tr>
<td width="100%" height="20" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
<tbody><tr>
<td align="center" class="pad20">
<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff;">
<tbody><tr>
<td width="100%" height="30" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td align="center" class="pad20">
<table width="450" border="0" cellpadding="0" cellspacing="0" align="center" class="full">
<tbody><tr>
<td valign="top" width="100%">
<table width="75" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="fullCenter">
<tbody><tr>
<td valign="middle" align="center" width="30" class="fullCenter" style="line-height: 1px;"></td>
</tr>
</tbody></table>
<table width="15" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="full">
<tbody><tr>
<td width="100%" height="10" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
<table width="350" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="fullCenter">
<tbody><tr>
<td width="100%" style="color: #111111; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 700; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px;" class="fullCenter">
Lorenzo Preciado
</td>
</tr>
<tr>
<td width="100%" style="color: #61b94d; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 600; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px text-transform: uppercase;" class="fullCenter">
<span style="color:#000000;">Web Designer & Developer </span>
</td>
</tr>
<tr>
<td width="100%" style="color: #929292; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px;" class="fullCenter">
Owner of Mid-Night Designs
</td>
</tr>
<tr>
<td width="100%" style="color: #929292; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px;" class="fullCenter">
+81 080-6499-4974 | help#mid-nightdesigns.com
</td>
</tr>
<tr>
<td width="100%" height="5" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td width="100%" align="center" class="icon18">
<!-- Social Icons -->
<table width="120" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="buttonScale">
<tbody><tr>
<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td width="100%" height="10" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
<tbody><tr>
<td align="center" class="pad20">
<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tbody><tr>
<td width="100%" height="30" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
<tbody><tr>
<td width="100%" valign="top" align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="mobile">
<tbody><tr>
<td align="center">
<table width="450" border="0" cellpadding="0" cellspacing="0" align="center" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; text-align: center;" class="fullCenter">
<tbody><tr>
<td width="100%" height="30" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td width="100%" style="color: #d2d2d2; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 12px; text-align: center; line-height: 24px;" class="fullCenter">
© Copyright - Mid-Nightd<span style="color:#FFFFFF;"></span>esigns.com
</td>
</tr>
<tr>
<td width="100%" style="color: #61b94d; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 12px; text-align: center; line-height: 24px;" class="fullCenter">
<br>
</td>
</tr>
<tr>
<td width="100%" height="50" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td width="100%" height="1" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</body>
</html>
This is the portion of the form
<label>
First Name
<input NAME="first_name" type="text" required="required" class="SV_validate" placeholder="First Name">
</label>
This is part of my email.php and it works, displaying the name in the email sent but doesn't work in the thank you.
$first_name = $_POST['first_name'];
PHP File that receives POST will be somewthing along the lines of
<?php
session_start();
$_SESSION['Name'] = $_POST['first_name'];
?>
Second File will be
<?php
session_start();
echo $_SESSION['Name'];
?>
Not recommended to do exactly that but that's the basis. You also can't set a session on the same page and call it on the same page.
Please check the simple scenario created for you, change the form action to thank-you.php file.
index.php
<form action="thank-you.php" method="post">
<input type="text" name="firstname">
<input type="text" name="email">
<input type="submit" name="contact" value="Contact">
</form>
thank-you.php
<?php
include_once('email.php');
$firstname = '';
if(isset($_POST['firstname'])) {
$firstname = $_POST['firstname'];
}
?>
<div class="message">Thank you for contacting - <?php echo $firstname;?></div>
email.php
<?php
if(isset($_POST['contact'])) {
$to = 'email#example.com';
$subject = 'Contact';
$message = 'Message';
if(mail($to,$subject,$message)) {
echo "mail sent";
}
}
?>
Well I have been at this for hours now. I'm using HTML2PDF to generate an invoice. My program creates a temporary invoice without issue. The issue I'm having is once the program tries to create a PDF from the temp file I'm getting an error:
ERROR n°5
File : /home/x/public_html/office/cron/invoices/php-pdf/_class/parsingHtml.class.php
Line : 218
HTML code invalid, all tags must be closed.
Status :
Array
(
[0] => page
[1] => table
[2] => tr
[3] => td
[4] => table
[5] => tr
[6] => td
)
I understand its saying all the HTML tags have not been closed. I've validated my code many different times, many different ways and sites and all are returning valid. I had some style issues that have been fixed but I still have no luck. My html is as follows:
<!doctype html>
<html>
<head>
<title>Untitled Document</title>
<style>
<!--
body {font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;}
.center {text-align:center;}
.ltgray {color:#C5C5C5;}
.invoice {vertical-align:text-top;}
.gbk td {background-color:#EDEBEB; border:none; font-size:13px; padding-bottom:8px; padding-top:8px; padding-left:10px}
.btboader { border-bottom:thin dotted; border-color:#E4E2E2; padding-bottom:8px; padding-top:8px; padding-left:10px }
.ltgrayt {color:#969696;}
.center {align-content:center; font-size:12px; font-weight:bold;}
.db {border:thin dotted; background-color:#EDEBEB;}
.padded {padding-left:15px;}
.hr { border: 0; height: 1px; background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); }
-->
</style>
</head>
<body>
<table style="width: 100%">
<tr>
<td class="invoice"><h2 class="ltgray">Invoice</h2> </td>
<td style="float: right">
<table>
<tr>
<td>Date:</td> <td> 03/12/2015</td>
</tr>
<tr>
<td>Invoice #:</td> <td> 100367</td>
</tr>
<tr>
<td> Propery </td> <td> N/a </td>
</tr>
</table>
</td>
</tr>
</table>
<p></p>
<table style="width: 95%; margin: 0 auto;">
<tr>
<td style="width: 50%"><span class="ltgray">Company Information</span><br />
<strong>XXX</strong><br />XXXX<br />XXXX</td>
<td style="width: 50%"><span class="ltgray">Customer Information</span><br />
<strong>XXXX</strong><br />XXXX<br />
XXXX<br />XXXX<br />Phone: XXXX<br />Email: XXXX</td>
</tr>
</table>
<br /><p></p>
<table style="width: 100%" class="tbl">
<tr class="gbk">
<td style="width: 60%"><strong>Item</strong></td>
<td style="width: 15%"><strong>Price</strong></td>
<td style="width: 10%"><strong>Qty</strong></td>
<td style="width: 15%; margin: 0 auto;"> <strong>Total</strong> </td>
</tr>
<tr>
<td style="width: 60%" class="btboader">Mulch - Red</td>
<td style="width: 15%" class="btboader">$2.50</td>
<td style="width: 10%" class="btboader">153</td>
<td style="width: 15%; margin: 0 auto;" class="btboader">$382.50</td>
</tr>
<tr>
<td style="width: 60%" class="btboader">Mulch - Black</td>
<td style="width: 15%" class="btboader">$3.50</td>
<td style="width: 10%" class="btboader">1</td>
<td style="width: 15%; margin: 0 auto;" class="btboader">$3.50</td>
</tr>
<tr>
<td style="width: 60%" class="btboader">Mulch - Brown<br><small>Bagged mulch, price includes delivery - Total 2 1/2 pallets</small> </td>
<td style="width: 15%" class="btboader">$3.50</td>
<td style="width: 10%" class="btboader">160</td>
<td style="width: 15%; margin: 0 auto;" class="btboader">$560.00</td>
</tr>
<tr>
<td colspan="2">
<table style="width: 100%">
<tr>
<td style="width: 20%">Payment Terms:</td>
<td style="width: 80%">Due On Receipt</td>
</tr>
<tr>
<td style="width: 50%">Discount(%):</td>
<td style="width: 50%">10.0</td>
</tr>
<tr>
<td style="width: 50%">Past Due Amount:</td>
<td style="width: 50%">$0.00</td>
</tr>
</table>
</td>
<td colspan="2">
<table style="width: 100%">
<tr>
<td style="width: 50%" class="ltgrayt">Subtotal:</td>
<td style="width: 50%; float: right;">$946.00</td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Tax (6.5%):</td>
<td style="width: 50%; float: right;"> $0.00</td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Discount:</td>
<td style="width: 50%; float: right;"> $94.60</td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Past Due:</td>
<td style="width: 50%; float: right;"><strong> $0.00 </strong></td>
</tr>
<tr>
<td style="width: 50%" class="ltgrayt">Total:</td>
<td style="width: 50%; float: right;"><strong> $851.40 </strong></td>
</tr>
</table>
</td>
</tr>
</table>
<br /><br />
<table class="db" style="width: 80%; margin: 0 auto;">
<tr>
<td><strong class="padded"><small>Order Notes:</small></strong><br /><p class="padded">Thank you for your business!</p>
</td>
</tr>
</table>
<hr class="hr">
<p class="center">XXXX, XXXX, XXXX - Phone: XXXX - Direct Cell: XXXX Email:XXXX<br />
Please make checks payable to: XXXX</p>
</body>
</html>
What am I missing that's causing this error? The only other thing I could think of is that HTML2PDF doesn't support something in my styling. I use HTML2PDF for another project without issue so Im not sure where I made a wrong turn.
i have a table created by my sql equijoin
and i want to retrieve data from that table by am getting error
the error is
dname.resource doesn't exist
and the code is
<style type="text/css">
a
{
text-decoration:none;
}
.Menu
{
width:150px;
float:left;
}
.fr
{
width:800px;
height:800px;
float:right
}
</style>
<div class="Menu">
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbanme");
$sql="select * from NSEIndices_latest";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$tpnt=$row['TickerPlantCode']; //nse indice code
$indexname=$row['IndexName']; //nse indice index name
?>
<tr>
<td><?php echo $indexname;?><br></td>
</tr>
<?php }?>
</div>
<div class="fr">
<iframe height="780" width="780" scrolling="no" name="fr"></iframe>
</div>
the gtnsegainer.php page on am getting error is
the gtnsegainer page is in iframe
this page retrieve data from database according to the link on the above page
<table class="table" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9;">Company Name
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">High
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Low
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Last Price
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Prv Close
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Change
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">%Gain
</th>
</tr>
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$tpnt=$_GET['tpnt'];
$indexname=$_GET['indexname'];
$query="SELECT nsepricequotes_latest.Symbol, nsepricequotes_latest.CompanyName, nsepricequotes_latest.HighPrice, nsepricequotes_latest.LowPrice, nsepricequotes_latest.LastTradedPrice, nsepricequotes_latest.ClosePrice, nsepricequotes_latest.NetChange, nsepricequotes_latest.PercentChange, nse_index_constituents.Tickerplant_index_code
FROM nsepricequotes_latest, nse_index_constituents
WHERE nsepricequotes_latest.TickerPlantCode = nse_index_constituents.TickerPlant_scrip
AND PercentChange >0
ORDER BY PercentChange DESC ";
$result=mysql_query($query);
$query1="Select * from $result where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
while($row=mysql_fetch_array($result1))
{
$symbol=$row['Symbol'];
$CompanyName=$row['CompanyName'];
$HighPrice=$row['HighPrice'];
$LowPrice=$row['LowPrice'];
$previousclose=$row['LastTradedPrice'];
$ClosePrice=$row['ClosePrice'];
$netChange=$row['NetChange'];
$percentagechange=$row['PercentChange'];
?>
<tr>
<td align="left" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $CompanyName;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $HighPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $LowPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $previousclose; ?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $ClosePrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $netChange;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $percentagechange;?></td>
</tr>
<?php } ?>
</table>
it is hard to tell what your error is, in your particular setup, but i recommend adding some simple debugging as such, after each mysql_query($query); add if(mysql_error())die(mysql_error()); and that will point you in the right direction.