Page 1 of 1
Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 7:28 am
by Todlerone
Hello everyone. Hope all is going well. I have a table that displays the contents of a MySQL query. This all works perfectly well. My question is since there is an date column in it, is there a way to have the displayed table shift daily to place the current row always at the top but still allow for scrolling of previous and future dates.
Thanks in advance
CHEERS
Re: Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 8:04 am
by aceconcepts
Don't really understand

Re: Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 8:25 am
by Todlerone
Sure. I have a MySQL populated table. One of the columns is for a corresponding date. This is a schedule for a baseball league. So basically there is date, park and visitor vs. home columns. I was just wondering if my table can shift daily to place the closest date (row) at the top of the visible table instead of having it with the first row of the populated table. I don't want to lose the data (rows) previous to the current date, just shift them out of view. This way when someone comes to the web site the schedule reflects the games coming up soon and prevents them from having to scroll down to find the current games. This help?
CHEERS and thank-you for the response.
Re: Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 8:31 am
by aceconcepts
If I understand you correctly, you could just use ORDER BY in your query when you fetch the data.
Am I missing the point?
Re: Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 9:43 am
by Todlerone
I actually do have order by date in the query. Sorry hard to describe my thoughts. My wife says I have the same problem. My response to her is....hello MALE. Just kidding. Say I have a table with each row starting with a date to reflect each day of the year. Now say july 3rd I go to visit the web page. What I want to do is have the table (the visible part) align the data within itself so that the July 3rd row is at the top of the visible table and if I want to see the other part of the data I just scroll. Basically the table will be quite long given the number of games in the table. Think of it like the Range Finder game in The Price IS Right. (don't we all watch this show @11:00am when we call in to work sick..hehe..for us Eastern time people). The same effect happens in many web pages where you can select an element and it throws you down the web page to that part of it only then you select the "Back to top" link.
This help..?
Re: Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 10:35 am
by timsewell
Sure - you ORDER by date in the query as previously stated. Set a variable in php to represent the current date then when building your table html (which I presume you do in a loop) add in a conditional to simply add an anchor link to the table row corresponding to that variable. Then refresh the page with the anchor appended to the URL.
Re: Reposition a MySQL data table to todays date
Posted: Thu May 15, 2008 10:41 am
by Todlerone
timsewell wrote:Sure - you ORDER by date in the query as previously stated. Set a variable in php to represent the current date then when building your table html (which I presume you do in a loop) add in a conditional to simply add an anchor link to the table row corresponding to that variable. Then refresh the page with the anchor appended to the URL.
Thank-you and aceconcepts for your patience and help....CHEERS I will try it.