Results 1 to 2 of 2
Jan 23, 2005, 19:17 #1
- Join Date
- Oct 2004
- 0 Post(s)
- 0 Thread(s)
Displaying other adverts from same category
I have a classifieds section in a site i am developing. It allows classified adverts to be viewed by section and then each advert to be viewed in detail.
I have a classified_adverts table which has an advert_id and also class_sect (the section it belongs to).
The class_section table has an id and the name of the section.
On the view_advert.php I display all of the details about the advert, i also want to display links to other adverts in the same section.
When viewing the view_advert.php page, the querystring has the id of the advert and also the classified section id - ie view_advert.php?advert_id=4&sec_id=1
So i have a recordset that selects the details about the advert;
SELECT advert_id, class_sect, ad_title, ad_body, ad_price, ad_contactEmail, ad_contactPhone, ad_contactName, item_photo, DATE_FORMAT(date_created,'%D %M %Y') as date_posted
WHERE advert_id = advert
advert gets its value from $_GET['advert_id']
I then have a recordset that selects records where the classified section is the same as the id in the querystring and the advert_id is NOT = to the advert id:
SELECT advert_id, class_sect, item_type, ad_title
WHERE class_sect = section AND NOT advert_id = advert
ORDER BY item_type ASC
But the second record set it not returning any adverts, although there are other adverts in the same section. I have run my query on the command line in my terminal session and it returns an empty set.....
Is this the best way to go about what I am trying to achieve and I have just made a stupid mistake with my SQL OR is there an easler/better way of achieving this?
Thanks in advance.