473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

limit results by user

155 100+
what is the code for limiting results sent from users?

i want to give limit to users that they cannot have 5 results in a row ,they can only have 4 rows in a row ,and if they post again and it's one of the 5 in the row it will be deleted?

1 user1 345
2 user1 275
3 user1 954 <=== this one was the last that was posted and will be deleted
4 user1 352
5 user1 356

and never mind which post was last ,it can be 3,1,2,5,4

thanx
Nov 8 '08 #1
2 1470
bilibytes
128 100+
the question is not very clear,

if you want to limit the number of insertions, you should count the number of rows for a user and then from PHP or whichever language you use, tell:

Expand|Select|Wrap|Line Numbers
  1. if($mysql_num_rows($result) < 4){
  2. -> sql code to insert the row into table.
  3. }
  4. else{
  5. -> prompt the user that he cannot add a row.
  6. }
  7.  
if you want to erase from your tables the rows above 4 for each user, you shoud make a query which would count the number of rows for each user and get the date added.
Once you get that date delete from table all values where date > date

if you don't use dates to order your posts, then you could use what ever you want, but the idea is to get the max allowed value, and delete the values that are above that one.
Nov 10 '08 #2
canabatz
155 100+
is it possible in php to count in a row?

like:

this is going in ORDER DESC

username | price

user 1 | 200
user 1 | 199
user 1 | 198
user 1 | 197
user 1 | 196
user 2 | 195
user 2 | 194
user 2 | 193

user 1 have 5 results in a row ,user 2 got 3 in a row , what im looking for is to limit the user to have 4 results maximum !

this is good !!

user 1 | 200
user 1 | 199
user 1 | 198
user 1 | 197 4 in row
user 2 | 196 1 in the row
user 1 | 195
user 2 | 194
user 2 | 193

if a user enter a price that is going to be between the 4 ,then it will be as 5 in a row!

hope you got me better now :)

thanx
Nov 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nick | last post by:
Is there a (better) way to get the toal number of results from a query but still limit them with a LIMIT clause. For example, in a Google search result, it displays 1-100 of 10,000,000 results. Do...
4
by: emily_g107 | last post by:
Hi, I need to limit results in the following query type: ...
0
by: D. Dante Lorenso | last post by:
I need to know that original number of rows that WOULD have been returned by a SELECT statement if the LIMIT / OFFSET where not present in the statement. Is there a way to get this data from PG ?...
6
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
3
by: markon | last post by:
Hi, I would like to run few lines of code and limit the time. If the procedure would not be finished say in 1000ms I would like to stop processing it. Unfortunately I do not know where to...
7
by: veliscorin | last post by:
hi experts, the topic is rather misleading but i couldn't find a better way to phrase it.. here's my scenario: Table A: Products Table B: Attributes (with a product_id to show which product it...
4
by: whizzkid1892 | last post by:
Hi, I have a movie database set-up and would like to create coding to show each movie in the database on its own page, and give the user links in a "page 1, page 2...." type navgation system. I have...
2
by: canabatz | last post by:
i got this code: $sql_f="SELECT reg_id, count(bid_price) as cnt, min(bid_price) as low FROM `bidding_details` where bid_id='$bid_id' and sortbid = '1' group by reg_id HAVING COUNT(reg_id) > 9 ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.