I am trying to print out the results of a sql query into a table i haven't finished the table yet but im already getting an error please help the error is Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\minterface.php on line 45

<!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>
				
			<?php
			$connection = mysql_connect("localhost", "root", "");
			$database = mysql_select_db("main", $connection);
			$school_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 ";
			$school_result = mysql_query($school_query);
			$school_rows = mysql_num_rows($school_result);
			?>
		<p>
			<table border="1" cellspacing="1" cellpadding="6">
			<tr>
			<th>ProductID</th>
			<th>Printer Model</th>
			<th>PartID</th>
			<th>Manufacturer</th>
			<th>PartNo</th>
			<th>Cost</th>
			<th>Description</th>
			<th>Quantity</th>
			</tr>

			<?php
				$i = 0;
				
				while($i < $school_rows)
				{	
					$productID=mysql_result($school_result,$i, "productID");
				}
			?>

			<tr>
			<td><?php echo $productID; ?></td>
			</tr>

			<?php
				$i++;
			?>

			</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 © 
			</div>
		</div>
	</div>
</div>

</body>
</html>

That message is basically telling you that the MySQL query failed. Do all the rows, cols, fields in your MySql query exist in the database?

Yes they all exist & i tested the sql in local host which worked.

You can also use this to help you debug.

$school_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 ";
if(!$school_result = mysql_query($school_query)) {
echo mysql_error();
}else{
$school_rows = mysql_num_rows($school_result);
}
?>

Its told me where the erroe is but im not sure whats wrong with it
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''part', 'printer', 'tracking' WHERE printer.printerID = part.printerID AND part.' at line 1

Try this.

$school_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 ";
if(!$school_result = mysql_query($school_query)) {
echo mysql_error();
}else{
$school_rows = mysql_num_rows($school_result);
}
?>

Still no luck with that piece of code still an error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''part', 'printer', 'tracking' WHERE printer.printerID = 'part.printerID' AND part at line 1

Ive fixed the sql but the page is taking ages to load.

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.