I am asking for help on the PHP scripting needed to display the results of an SQL query to a MySQL database. I can manage the basic display by row in the result array using a 'while' statement but I cannot manage a particular display requirement.
I have two tables : widgets and images
Widgets table has columns for 'widget_ID', 'description', 'price' and
Images table has columns for 'image_ID', 'widget_ID', 'filename', 'size' (for the moment size is either "regular" or "thumbnail")
The SQL query I have written is :
"SELECT widgets.widget_ID, widgets.description, widgets.price, images.filename, image_ID, size FROM widgets, images WHERE widgets.widget_ID = images.widget_ID ORDER BY widgets.price ASC"
and this query produces the correct results. But because the relationship of the widgets table to the images table is 'one to many', I get multiple lines per widget_ID. (each line is distinct)
I want to create an HTML display in TABLE form with two cells per line (this is no problem) but I want only one cell per Widget_ID and I need this cell to contain all the filename references for the images applying to that widget_ID ( I don't want only one image filename per cell nor do I want multiple cells per widget_ID)
I have tried splitting the join SQL query above into two separate queries : one for the widget table and one for the images table but then I cannot get the PHP code right for creating the display I want.
Any ideas please ?