php - limit the number of a field value in search results -


I run a real state website that allows different users to add their properties. When someone searches for specific criteria, we use a selection statement with the specified conditions to select matching properties, paging bit and displaying results.

We use rating algorithms to rate each asset and use it for the preferences of properties displayed.

A simplified version: Type Type Bedroom User Score Green House Sales Two Bedroom Alex 6 Blue One Hire Three Bedroom Jack 6 Blue One Sale Three Bedroom Jack 4 Gray One Sale Three Bedroom Jack 6 green fare three bedroom jack 6 purple one fare three bedroom jack 6 green one rent three bedroom jack 6 green one rent three bedroom gary 6

The problem is that sometimes One of the few properties In these cases I do not want a user to possess the property to dominate a search results page in these cases, I want to set a limit to display the maximum of three qualities of any user in a search results page.

For example, I do not want Jack owned property to dominate the first page, and the properties of other users will go to the second page. This will disturb other users and create bad experiences for visitors.

If I want to show only one asset for a given user, then I will use the group, but I am not sure whether the limit is limited to a large number (for example three) Can I do anything to get this?

EDIT:

Sorry if it was not clear enough.

The usage field shows a user who adds a special property can be a sample question

  select properties from WHERE type = 'sale' LIMIT 5 order According to the order   

the result can be five properties, by all added jack, I want to make sure that the assets are not added by you by a particular user, the results are included in the Other users like this Get the chance to show the added properties by s.

Use DISTINCT to resolve your problem. In one table, there may be several duplicate values ​​in one column; And sometimes you just want to list different (different) values. Different keywords can only be used to return different (separate) values ​​Example: Select from a different table_name user;

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -