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>

Recommended Answers

All 10 Replies

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?

I removed the tag and the code still didnt work.

What do you see when you look at the page source?

i see the code im using

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();
?>

I get the php version info, version is 5.3.1.

Is the other file saved with a .php extension?

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

In your query, you need to use backticks (`) around column names, not quotes (')

Still have the same error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.