Hi Guys,
Never mind, I know this should be posted in the MySQL or Database forums but I am posting it here because to have more peoples’ views.
Okay, I have a listing page where the records are listed and I can filter the records from search form (about 5/6 fields) and also choose ordering field and order by. With three conditions, I have following query:
SELECT
p.id,p.title,p.views
FROM
jos_prpt_properties AS p
INNER JOIN jos_prpt_agents AS a ON p.agent_id=a.id
INNER JOIN jos_prpt_type AS pt ON p.property_type=pt.id
INNER JOIN jos_prpt_listingtype AS lt ON p.listing_type=lt.id
INNER JOIN jos_prpt_features AS f ON p.id=f.property_id
INNER JOIN jos_prpt_locations AS l ON p.id=l.property_id
INNER JOIN jos_prpt_availablilties AS av ON p.id=av.property_id
INNER JOIN jos_prpt_prices AS pr ON p.id=pr.property_id
WHERE p.published=1 AND lt.reference_id IN(1,3) AND f.bedrooms>=4
ORDER BY views DESC;
So first of all, suggest me if I am doing something wrong in my joining ;).
There will be pagination if more records are found. Search criterias are stored in cookies because the client himself wants if a visitor selects once some filtration options then the same filtration should remain next time when he visits the page.
Now when a record is clicked and went to the details page, there is again a navigation as Previous | Next which should show the records in the same way/ordering how they were shown in listing page. So what I am thinking is; instead of passing the id I would just pass the index number of the record. Lets say if there are 35 records listed in the listing page then I will pass 10 for the 11th record in the listing/result and I will hit the following query in the detail page:
SELECT
p.id,p.title,p.views
FROM
jos_prpt_properties AS p
INNER JOIN jos_prpt_agents AS a ON p.agent_id=a.id
INNER JOIN jos_prpt_type AS pt ON p.property_type=pt.id
INNER JOIN jos_prpt_listingtype AS lt ON p.listing_type=lt.id
INNER JOIN jos_prpt_features AS f ON p.id=f.property_id
INNER JOIN jos_prpt_locations AS l ON p.id=l.property_id
INNER JOIN jos_prpt_availablilties AS av ON p.id=av.property_id
INNER JOIN jos_prpt_prices AS pr ON p.id=pr.property_id
WHERE p.published=1 AND lt.reference_id IN(1,3) AND f.bedrooms>=4
ORDER BY views DESC
LIMIT 10,1;
So that I can just increment the index for Next record and decrement the index for Previous record.
Hope I described it clearly. If it is not clear to you, feel free to ask for
So can you point out some pitfalls with this method or suggest some better ways to handle the situation or how you guys are handling this type of situation?
Thank you so much guys in advance for reading the long description.
Raju Gautam