Try using '$id' : SELECT properties.area, images.image_filename FROM properties, images WHERE properties.reference_number=images.reference_number AND properties.area='$id'
On Mon, 2003-12-08 at 23:18, fatblokeonbike wrote: > . > I'm new to MySQL joins with PHP and I can't get this to work - and I don't > understand *why* it won't work. > > Table 1 - Countries - has fields: country > Table 2 - Properties - has fields: area, reference_number > Table 3 - Images - has fields: image_filename, reference_number > > The first page goes - > > $Query="SELECT country FROM countries"; > $Result=mysql_db_query ($DBName, $Query, $Link); > while ($Row=mysql_fetch_array($Result)) > { > print("<a href=\"country.php?id=$Row[country]\">$Row[country]</a><br>"); > } > > The visitor, wanting to see an area, clicks on a particular country's link > and arrives in the country.php page, which contains - > > $id = $HTTP_GET_VARS["country"];. > > $Query="SELECT properties.area, images.image_filename FROM properties, > images WHERE properties.reference_number=images.reference_number "; > > This works, but it delivers the images of every country. To call the images > from just one country, I try - > > $Query="SELECT properties.area, images.image_filename FROM properties, > images WHERE properties.reference_number=images.reference_number AND > properties.area=$id"; > > but it doesn't work - I get the usual "...not a valid MySQL result resource" > > I've played around with it, but I confess myself beat. I expect the > answer's terribly simple - but then, as everyone keeps telling me, so am I. > > If you can help, thanks in advance. > > Iain. -- Diana Soares -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]