Click here to Skip to main content
15,506,385 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i am building a b2b website where user can post the lead requirement and seller can buy this leads according to their plan. but there is one condition, the post leads will show first to the high priority plan subscribers then other plab subscribers.

i try everything but not getting any idea to do this.

Here is my table structure for leads and plans and users

table leads

id | full_name | email_id | mobile_no | company_name | product_name | product_desc | purpose | quantity | unit | order_value | supplier_city | supplier_state | supplier_country | requirement_time | status | date_created | time_created

table plans

id | plan_name | lead_allocated | plan_count | plan_unit | leads_per_week | price | plan_desc | plan_image | status | priority | date_created

table users

id | personal_name | mobile_no | email | username | password | plan_id | date_created

i am using php as server side script and mysql database, and using core php. please give me any suggestion to do this.

What I have tried:

not getting any idea, how to do this.
Updated 26-Jun-21 23:27pm

First off, you probably need to change that table design - you should never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]

And remember: if this is web based and you have any European Union users then GDPR applies and that means you need to handle passwords as sensitive data and store them in a safe and secure manner. Text is neither of those and the fines can be .... um ... outstanding. In December 2018 a German company received a relatively low fine of €20,000 for just that.

Second - change your leads table to replace the "date_created" and "time_created" columns to a single timestamp column - DATETIME is fine - and use that as the basis for deciding if a lead should be shown.
Add a column to the Users table which is the delay in minutes between a lead being posted, and it being shown to this user. You can then use the SQL DATEADD function[^] to generate a "valid time" for showing the lead. Compare that with the SQL GETDATE function[^] and only display if it is greater than or equal to,
Share this answer
To add a bit more details to the previous answer by OriginalGriff, to choose proper type for the columns use one which contains both date and time. This way it's easier to calculate with the date. DATETIME is one option along with TIMESTAMP. For more information, see MySQL :: MySQL 8.0 Reference Manual :: 11.2.2 The DATE, DATETIME, and TIMESTAMP Types[^]

When setting the value for that column you can use either MySQL :: MySQL 8.0 Reference Manual :: 12.7 Date and Time Functions[^] or MySQL :: MySQL 8.0 Reference Manual :: 12.7 Date and Time Functions[^]

Once you have the date (and time) in place you can compare it to now or sysdate and for example shift the time forward as much as you need using MySQL :: MySQL 8.0 Reference Manual :: 12.7 Date and Time Functions[^]

For example if you want to check that three hours has passed from creating a row it could look something like
FROM ...
WHERE ADDTIME(Created, '03:00') < SYSDATE()
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900