Page 1 of 1

Arranging a thumbnail gallery via categories

Posted: Wed Apr 14, 2010 8:56 pm
by hellsnells
Hi guys,

I've recently started learning PHP as I've received a job to update a jewelry website which relies heavily on PHP and MYSQL, with an admin area to add and delete products.
Anyway, I've managed to successfully make the changes the client wanted but I have become stuck on one thing that I just haven't been able to solve!

There is a shopping page where the client wants category headings for the jewelry (i.e- Earrings, Necklaces, etc), and all thumbnails for each relevant category displayed under the header as thumb rows.

For the life of me I cannot work out how to assign the thumbnails to the appropriate headings. I keep getting all the headings, then nothing underneath.

- The information is pulled from a database named "products".
- The column "cat" are the product category headings
- I want to sort the column "product_image" by its category "cat"

I feel like the soltuion is a simple one but I just can't work it out! I've searched for endless tutorials and done heaps of reading. Maybe I don't know what to look for.
This is really a last resort as the deadline is looming!


Below is the code I have been working from. It is only the bones but I hope it's enough to show you:

Code: Select all


<?php


define('TITLE', 'Pauline Daniel Shopping');

include('header.html');

include('db.php');

print'<h1>Pauline Daniel Jewellery - Shopping</h1>

$query = 'SELECT * FROM products ORDER BY cat ';

		

			if($r = mysql_query ($query)){

		

			while($row = mysql_fetch_array($r)){
			
			print'<table cellpadding="0" cellspacing="0" width="900"><tr>
		
			<td valign="top"><h1>'.$row['cat'].'</h1>
			</td></tr></table>';
	


print'<a href="products.php?id='.$row['product_id'].'"><img src="images/products/'.$row['product_image'].'" style="padding:1px; border:1px solid #ffffff;" border="0" hspace="7" vspace="7" width="133" align="middle" ></a>';

print'<p><img src="images/dot.jpg" width="860" height="1"></p>';

}
}


			mysql_close();


include('footer.html');

?>

Do I need an "IF, WHERE" statement, like comparing the "product_image" to the "cat"?

Here's a link to the page: http://www.paulinedaniel.com/shop.php

I would GREATLY appreciate any help!!!!!

Thanks in advance.