close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Increase ID by one every 7 days

Thread began 5/19/2010 10:51 am by John Langer | Last modified 6/21/2010 8:22 am by John Langer | 3858 views | 42 replies

CraigRBeta Tester

Hi John,

Jason's approach is obviously different to mine, and I can't quite get my head around it.

I can only go through my last approach, which would seem to offer a solution, regardless of the number of rows.

SELECT * FROM toptenlist
WHERE topTenListID = (mod(round((datediff(curdate(), '2008-10-10')/7),0),3)+1)

2008-10-10 is just an arbitrary date

(in the example above, i used a modulus of 3 (in red), but this number should be the same as the number of rows in the table.

what this (hopefully) does, is return an integer between 1 and 3, which will be one of the three rows in the table.

What the equation does is this...
calculates the number of days between the current date and an arbitrary date, divides this number by seven, so we have the number of weeks between these 2 dates, rounds this number so we get an integer value returned, then takes a modulus of this number, based on the number of rows in the table.
This should return either a 0, 1 or 2 in the case of a modulus of 3.
By adding 1 to this value, we get 1,2 or 3, which are the row id's
The integer returned will depend on the difference between the current date and the arbitrary date.

I have tried putting different arbitrary dates into the equation, and it seems to work, though you may want to test it more thoroughly.

Hopefully Jason will come back on this, as his approach seems a little neater, but I can't quite work it out.

Hope this helps

PS What I will do this morning is try it with a table of x rows and ensure it behaves as i think it should.


Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...