Jump to content


Check out our Community Blogs

TenLeftFingers

Member Since 26 Dec 2011
Offline Last Active Dec 06 2012 09:25 AM
-----

Posts I've Made

In Topic: [SOLVED] Why Is This Inline Statement Php Breaking My Tables?

14 July 2012 - 08:53 AM

I've tracked the problem down to a mismatched brace in my php function :rolleyes: . I still don't know why it only caused a problem with the inline php and not in other cases, but the issue is resolved.

Thanks for your help Orjan.

In Topic: [SOLVED] Why Is This Inline Statement Php Breaking My Tables?

14 July 2012 - 06:39 AM

I have tried removing the inline php and doing it this way, but I still get the same results:
function drawTable($objects, $exclusions="")//exclusions isn't implemented yet, but needs
{		   //to take the fields not to print and omit
$class = get_class(array_pop($objects));
echo '<p class="' . $class . '"></p>';
?>		 
Beginning Table Print<br />
<table><!--id="rounded-corner" -->
    <thead>
	 <tr>
	 <?php
	 foreach ($objects as $object)//iterate headers to make th's
  {
   $loopCount = 1;
   $vars = get_object_vars($object);
   foreach ($vars as $key => $val)
   {
	 if ($key == get_class($object) . "Id")
	 {
	    continue;
	 }
	 if ( $loopCount == 1 )
	 {
	   echo '<th scope="col" class="rounded-company">'. ucfirst(pascalSpaces($key)).'</th>';
	 }
	 else if ( $loopCount == count($vars)-1 )
	 {
	   echo '<th scope="col" class="rounded-q4">'.removeId(ucfirst(pascalSpaces($key))).'</th>';
	 }
	 else
	 {
	   echo '<th scope="col">'.removeId(ucfirst(pascalSpaces($key))).'</th>';
	 }
	 $loopCount++;
  }
  ?>
	    </tr>
    </thead>
    <tfoot>
	 <tr>
	 <?php
		 foreach ($objects as $object)
		 {
	 $vars = get_object_vars($object);
		   echo '<td colspan="' . (count($vars)-2) . '" class="rounded-foot-left">
			 The above data represents <u>' . get_class($object) . '</u> records.
			  Blank spaces represent absent values.</td>';
		   break;
		    }
	    ?>
	
		 <td class="rounded-foot-right">&nbsp;</td>
	    </tr>
    </tfoot>
    <tbody>
	
	 <?php
	    foreach ($objects as $object)
	    {
   echo '<tr>';
  
		 $vars = get_object_vars($object);
		 foreach ($vars as $key => $val)
		 {
		   if ($key == get_class($object) . "Id")
	   {
		  continue;
	   }
			  echo '<td>' . $val .'</td>';
		    }
		    echo '</tr>';
  
	    }
	    ?>
	   
    </tbody>
    </table>
Ending table print<br />
    <?php
		    break; //we don't need to get paramaters for other similar objects.
  }
}  //end drawTable function 

In Topic: [SOLVED] Why Is This Inline Statement Php Breaking My Tables?

14 July 2012 - 05:53 AM

I have reduced the code considerably to isolate the error. I get 0 errors now when I use:
<p class="patient"></p>
above each table.
But when I add inline php:
<p class="<? echo "patient" ?>"></p>
I get messed up html in the output. It's strange, because if you view the source of www.barryreidy.com/testing/session.php , the <p> is place *inside* the later tables. (all tables are generated with the same function.

The validator points to the problem on line 65 of the source: http://validator.w3....C_Validator/1.3

One thing is for certain, the inline php is causing this. It is obviously not returning a clean string, but has some non-printing characters coming back with it. I have no idea how to debug this further.

In Topic: [SOLVED] Why Is This Inline Statement Php Breaking My Tables?

13 July 2012 - 02:35 AM

yes, it is totally wrong. you open php with <?php and closes it with ?> and together it makes one tag (<?php ?>) within the html. the browser don't know about the <?php ?> tags at all, as it's removed by the php script while executing the content between.

upload your html to the html validator here http://validator.w3.org/ and see all the syntax errors you have in your html. (about 90 errors...)

Thanks Orjan, I can see that the "good" source has 81 errors and the "bad" source has 90 - which is a difference of 9. Hopefully those 9 errors contain a solution. I'll see what I can do today.

In Topic: [SOLVED] Why Is This Inline Statement Php Breaking My Tables?

12 July 2012 - 12:24 PM

what is all these <html> tags doing in the middle? the html tag is surrounding the whole page and is only used like that?
also, a complete html source instead of a diff makes it easier to look at, to find html errors, something you can post?

Whenever I switch from php to html I close the php: ?> and open html: <html>, then when I finish the html code, I close the html: </html>, and open the php again: <?php. Is this wrong?

I've attached the html for the page in the previous posts (but I saved the sources as session.php and session2.php). These are the two versions of the html output sources.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download