webdevRefinery Forum: Issues validating HTML5 within PHP - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline deucalion0 

  • Group: Members
  • Posts: 183
  • Joined: 05-September 10
  • LocationDundee, Scotland

Posted 30 April 2012 - 09:02 AM (#1)

Issues validating HTML5 within PHP


Hey guys, I didn't know whether to post this in t HTML or PHP, I guessed seeing as it was a Validation issue, I posted here. So basically in my products page, it has a lot of php which loops through code, to display products in tables. I have this error in the validator:

Error Line 165, Column 188: Start tag for table seen but the previous table is still open.

…e.jpg width='200' height='250' alt=''/></a></td></tr><table class='tabletry' >


Error Line 165, Column 188: Unclosed elements on stack.

…e.jpg width='200' height='250' alt=''/></a></td></tr><table class='tabletry' >

This I am assuming is because it cannot detect there is a closing table tag, which there is. Here is my PHP:

echo "<table class='tabletry' >
		<tr> <td>$row[1]</td></tr>
		<tr><td><a href='products.php?productID=".$row[1]."&amp;bask=m'><img  src=". $row[2] ."  width='200' height='250' alt='' /></a></td></tr>";
		$rowsRetrieved++;		
} 

while ($rowsRetrieved <= $rowsPerPage & $row = sqlsrv_fetch_array($stmt));

/* Close table. */
echo"</table><br/><br/><br/>";



Why is it that it does not detect the closing table tags? I don't have issues with other elements inside my PHP.

Any help at all would be great, I have tried to think of other ways to do this but I cant get anything working.

Thanks!
0


User is offline Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 30 April 2012 - 09:43 AM (#2)

Can you please post the entire php code? The code you have given us shouldn't even work, so I can't be 100% certain of this solution. But if I had to make a guess, I'd say you need to move
echo"</table><br/><br/><br/>";
inside the loop, that way each table gets ended, instead of just the last one.
Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
1


User is offline deucalion0 

  • Group: Members
  • Posts: 183
  • Joined: 05-September 10
  • LocationDundee, Scotland

Posted 30 April 2012 - 09:56 AM (#3)

I tried to avoid posting the whole code, due to its size, but here it is!:

	if($main == men)//If men link in sidebar is clicked
	{
		$baskimage='picturem';
		if (isset($_GET["pagenum"]))
		{
			$page  = $_GET["pagenum"];
		}
		else 
		{ 
			$page=1; $_GET["pagenum"] = 1;
		}
			
		/* Set the number of results to display on each page. */
		$rowsPerPage = 9;

		$tsql = "SELECT *
		FROM   (SELECT ROW_NUMBER() OVER(ORDER BY productID) AS
		RowNumber, productID, picturem, catalogueID FROM products WHERE category1 = '$category') AS products1
		WHERE  RowNumber BETWEEN ? AND ? + 1";

		$stmt1 = sqlsrv_query( $conn, "select * from products WHERE category1 = '$category'" , array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
		$recordcount =  sqlsrv_num_rows($stmt1);

		$last = ceil($recordcount/$rowsPerPage);

		/* Determine which row numbers to display. */
		if(isset($_REQUEST['lowRowNum']) && isset($_REQUEST['highRowNum']))
		{
			$lowRowNum = $_REQUEST['lowRowNum'];
			$highRowNum = $_REQUEST['highRowNum'];
		}
		else
		{
			$lowRowNum = 1;
			$highRowNum = $rowsPerPage;
		}

		/* Set query parameter values. */
		$params = array($lowRowNum, $highRowNum);

		/* Execute the query. */
		$stmt = sqlsrv_query($conn, $tsql, $params);

		/* Retrieve one row to see if there is any data. */
		$row = sqlsrv_fetch_array($stmt);
		if($row === false)
		{
			echo "Error in fetching row.";
			die( print_r( sqlsrv_errors(), true));
		}
		elseif($row[0] == 0) /* Special case of no data returned. */
		{
			echo "No data returned.";
		}

		else /* A row was retrieved! */
		{
			/* Set the number of rows that have been retrieved. */
			$rowsRetrieved = 1;
	
			do
			{
				echo "<table class='tabletry' >
						<tr> <td>$row[1]</td></tr>
						<tr><td><a href='products.php?productID=".$row[1]."&amp;bask=m'><img  src=". $row[2] ."  width='200' height='250' alt='' /></a></td></tr>";

				$rowsRetrieved++;
					
			} 
			while ($rowsRetrieved <= $rowsPerPage & $row = sqlsrv_fetch_array($stmt));

			/* Close table. */
			echo"</table><br/><br/><br/>";

			print("<div id='pagenum'>");
			/*If there are previous results, display the
			 Previous Page link.*/
			 
			if($lowRowNum > 1)
			{
				$prevp = $page-1;
				$prev_page_high = $lowRowNum;
				$prev_page_low = $lowRowNum - $rowsPerPage;
				$prevPage = "?main=men&amp;category1=1&amp;pagenum=$prevp"."&amp;lowRowNum=$prev_page_low".
						"&amp;highRowNum=$prev_page_high";
				print("<a class='left' href=$prevPage>".
						"Previous Page</a>&nbsp;&nbsp;&nbsp;");
			}

			/* If there are more results, display the Next Page link.
			 We know there are more results if the last call to
			sqlsrv_fetch_array returned a row (the "extra" row).
			*/
			if($row != false)
			{
				$next = $page+1;
				$next_page_low = $highRowNum;
				$next_page_high = $highRowNum + $rowsPerPage;
				$nextPage = "?main=men&amp;category1=1&amp;pagenum=$next"."&amp;lowRowNum=$next_page_low".
						"&amp;highRowNum=$next_page_high";
				print("<a class='right' href=$nextPage>Next Page</a>");
					
			}
		}
		echo " <br/><p class='pages'>--Page $page of $last-- ";

		print("</div>");
			
	}


I hope it is not too much to read! Thank you!
0


User is offline Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 30 April 2012 - 10:29 AM (#4)

Aha, it's exactly what I thought. Only the final table get's closed. If you do what I said in my last post it should work out fine.
Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
1


User is offline deucalion0 

  • Group: Members
  • Posts: 183
  • Joined: 05-September 10
  • LocationDundee, Scotland

Posted 30 April 2012 - 11:02 AM (#5)

:) OK, I will try what you said, hopefully this work!!! I will let you know!!! :)

Koen, I tried this before, but when I tried again, I still get the top three products stepping, like a step effect, being pushed down, although this only affects the top three items, the rest are in line. Do you have any idea what could be causing this?

Thanks you

Actually I got it to work, I was moving the <BR/> tags with the, now I am just moving the table tag, all this over that, I never got the idea to NOT move the break tags! :(

Cheers!!
:)
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services