Jump to content

tables inside tables?


arbitter

Recommended Posts

I have a php file with table-layout, but my td's don't line up( but they do)

 

I'll sketch it quickly:

<table>
   <tr>
      <td>//in notepad++ this doesn't get linked to the td aligned with this one
         <table> // this table is fully recognized until
            <tr>
               <td>
                 echo "Lot's and lots of content";
            </tr>
         </table>// until here. so that's not the problem
      </td>
   </tr>
</table>

 

And because of that, when I try to validate my file, it gives loads of errors...

 

(In notepad++ if you click on the beginning of a tag, it shows the endingtag too so you see if it's correct or not;)

how it should be: (and to show my table within the td is correct)

2pzywpl.jpg

 

the problem:

350uz9t.jpg

 

Link to comment
Share on other sites

You missed a closing </td> after

 

 echo "Lot's and lots of content";

 

 

<table>
   <tr>
      <td>//in notepad++ this doesn't get linked to the td aligned with this one
         <table> // this table is fully recognized until
            <tr>
               <td>
                 echo "Lot's and lots of content";
              </td>
            </tr>
         </table>// until here. so that's not the problem
      </td>
   </tr>
</table>

Link to comment
Share on other sites

Oh my bad, but in my file it's all closed, doublechecked it. So that's not the problem. I can give the whole thing, but it's kind of big and I don't think you'd really get out of it fast, so that's why I put it here simplified..

Link to comment
Share on other sites

The php is properly closed, no worries there. I'll post the whole thing

<table width="100%">
<tr>
	<td width="200" align="left" valign="top"> 
		<table width='200' align='left'>
			<tr>
				<td rowspan='100'> </td>
				<td colspan='2'> </td>
			</tr>
			<tr>
				<td height='100%' colspan='2'> </td>
			</tr>
			<tr>
				<td align='center' colspan='2'><b>Kies een maand</b></td>
			</tr>
			<?php
			/* Directories zoeken en rangschikken nieuw vanboven */
			$dirs = glob('*',GLOB_ONLYDIR|GLOB_NOSORT);
				foreach($dirs as $dir) {
					$sortedDirs[filemtime($dir)] = $dir;
				}
				ksort($sortedDirs);
				foreach (($sortedDirs) as $map)
					{	$qmap = urlencode($map);
						if(isset($_GET['sort'])){
							if(urlencode($_GET['month']) == $qmap){
								$kl1 = $kleurachtergrond;
								$kl11= $kleurletter;
							}
							else{
								$kl1='white';
								$kl11='black';
							}
							echo "<tr><td colspan='2' bgcolor='$kl1' width='200' align='center' valign='middle' style='cursor:pointer' onclick=\"location.href='?month=$qmap&sort&#61;$sort'\"><font color='$kl11'>$map</font></td></tr>";
						}
						else{
							if(urlencode($_GET['month']) == $qmap){
								$kl1 = $kleurachtergrond;
								$kl11=$kleurletter;
							}
							else{
								$kl1='white';
								$kl11='black';
							}
							echo "<tr><td colspan='2' bgcolor='$kl1' width='200' align='center' valign='middle' style='cursor:pointer' onclick=\"location.href='?month=$qmap&sort&#61;ksort'\"><font color='$kl11'>$map</font></td></tr>";}
					}

			/* als er een maand is aangegeven, word die opgeslagen in een sessie. Als die bestaat */
			$maand = $_SESSION['month'];
			$qmaand = urlencode($maand);
			if (isset($maand)){
			echo "<tr><td colspan='2'> </td></tr><tr><td colspan='2' align='center'><b>Sorteren op:</b></td></tr>";
				if($_GET['sort'] != 'ksort'){
					$kleur2 = $kleurachtergrond;
					$kleur22 = $kleurletter;
					$kleur1 = 'white';
					$kleur11 = 'black';
				}
				else{
					$kleur1=$kleurachtergrond;
					$kleur11 = $kleurletter;
					$kleur2='white';
					$kleur22='black';
				}
			echo 	"<tr valign='bottom'><td bgcolor='$kleur1' width='200' align='center' valign='bottom' style='cursor:pointer' onclick=\"location.href='?month=$qmaand&sort&#61;ksort'\"><font color='$kleur11'>oudste</font></td>
					<td bgcolor='$kleur2' width='200' align='center' valign='bottom' style='cursor:pointer' onclick=\"location.href='?month=$qmaand&sort&#61;krsort'\"><font color='$kleur22'>nieuwste</font></td></tr>";}
			?>
		</table>
	</td>

	<td width="824" align="left" valign="top"> <div class='first'>
		<?php 

				$images = glob($_SESSION['month'] . '/*.{jpg,gif,jpeg,pjpeg,image,JPEG}', GLOB_BRACE|GLOB_NOSORT);
if (isset($maand)){					
if (isset($images)){
					foreach ($images as $image)
						{$sortedimages[filemtime($image)] = $image; }
					if ($sort2 == 'ksort'){
						ksort($sortedimages);
						foreach (($sortedimages) as $afbeelding)
							{ echo "<br /><center><img src=\"$afbeelding\" class='first' alt='foto' /></center><br />";}}
					elseif($_GET['sort'] == 'krsort'){
						krsort($sortedimages);
						foreach (($sortedimages) as $afbeelding)
							{ echo "<br /><center><img src=\"$afbeelding\" class='first' alt='foto' /></center><br />";}}
					else{echo "&nbsp";}}
				else {echo " ";}}

		?>
		</div>
	</td>
</tr>
</table>

 

Link to comment
Share on other sites

My IDE was able to highlight both start and end tags for the <td></td>.  Maybe the problem happens when the page is rendered.  What does the error say when you validate it?  Check to see what the source looks like when it's rendered and try pasting that into Notepad++ to determine if the tags line up.

Link to comment
Share on other sites

Oh my how peculiar. I started editing my file yesterday, via w3c. But I got 53 errors, including the errors with the <td>. I patched up all the other 20 problems, (though I never interfered with any td,tr, or tables) and was wainting to see what to do with this. But by checking it now, with the other 20 errors fixed, it suddenly passed! Though notepad++ still doesn't link the two td's.

Anyway, it's validadet now, thanks a lot!

Link to comment
Share on other sites

Errors cascade. One error at the top of a document turns into 20 errors below it, as the validator gets confused. So it's always good to fix the first error, then re-test. If you start trying to fix errors further down the page, they may not actually be an error, and in fixing it, you just have to re-fix it later on.

Link to comment
Share on other sites

Indeed, but the only errors were som <br> instead of <br /> and forgot the alt='alt' in the images. Perhaps some other little flaws, so I didn't think that would interfere. Good to know that I have to test it after fixing a few errors, so I don't spam this forum!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.