This is my code and somehow it works.
Code:
<table border="1">
<?php

	mysql_connect("localhost", "root") or die("Cannot connect to database: ".mysql_error());
	mysql_select_db("db_pcaccess") or die("Cannot connect to database: ".mysql_error());
	
	$category = "Monitor";
	$query = mysql_query("SELECT * FROM tbl_products WHERE pcategory='".$category."'");
	
	$a = 1;
	while ($row = mysql_fetch_array($query))
	{
		if($a <= 3){ //number of cells in a row
			echo '<td>'.$row['pimage'].'</td>';
			$a++;
		}
		else{
			echo '</tr>\n<td>'.'<td>'.$row['pimage'].'</td>';
			$a = 1;
		}
	}
	echo '</tr>';
?>
</table>
The problem is i don't know where to put this code so that it tells the browser that the file would be a jpg file.
Code:
header('Content-type: image/jpg');
I tried displaying a single image without the table and it works. But when I add the table code and the loop, it doesn't display the images that I've put in the database. Please help. I'm only a beginner in PHP.