0

I am trying to put the results of my query into a table on my webpage that i have made however, i am having problems as it prints some of the code out onto the webpage & doesn't display the table.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<link rel="stylesheet" type="text/css" href="minterface.css"/>

<head>
<title>Mountbatten School Stock</title>
</head>
<body>

<div id="container">
	<div id="header">
		<h1>
			<img src="logo.gif"/>
		</h1>
	</div>
	<div id="navigation">
		<ul>
			<li><a href="#">Home</a></li>
			<li><a href="#">About</a></li>
			
		</ul>
	</div>
	<div id="content-container1">
		<div id="content-container2">
			<div id="section-navigation">
				<ul>
					<li><a href="#">Stock</a></li>
					
				</ul>
			</div>
			<div id="content">
				<h2>
					Stock Levels
				</h2>
				<p>
					Welcome, to the 
				</p>
				
				<p>
					<?php
					$connection = mysql_connect("localhost", "root", "");
					$database = mysql_select_db("main", $connection);
					$result= mysql_query("SELECT * FROM 'part', 'printer', 'tracking' WHERE printer.printerID = part.printerID AND part.partID = tracking.partID AND quantity BETWEEN 0 AND 3 LIMIT 0, 30 ");

					echo "<table border='1'>";
					echo "<tr> <th>Name</th> <th>Age</th> </tr>";

					while($row = mysql_fetch_array( $result )) {

					echo "<tr><td>"; 
					echo $row['name'];
					echo "</td><td>"; 
					echo $row['age'];
					echo "</td></tr>"; 
					} 

					echo "</table>";


				?>
				</p>
				<br />
				<br />
			</div>
			<div id="aside">
				<h3>
					Help
				</h3>
				<p>
					If you have any problems while viewing this page please contact IT support.
				</p>
			</div>
			<div id="footer">
				Copyright © Mountbatten School
			</div>
		</div>
	</div>
</div>

</body>
</html>
2
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by clueless07
0

In XHTML 1.0, you cannot use a table tag within a p tag.

When using p, any other block-level element will effectively close the p.

Does it work if you remove the paragraph tag?

Edited by Will Gresham: n/a

0

Ah, my mistake. I misread your first post to say it was not putting the data into the table :(

What happens if you create a file called phpinfo.php and put this code into it:

<?php
phpinfo();
?>

Edited by Will Gresham: n/a

0

Ive saved it with a php extension but im gettin an error now
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\minterface.php on line 49

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.