GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Sortable date on page from 3 seperate columns? (https://gfy.com/showthread.php?t=1359613)

Publisher Bucks 11-26-2022 07:39 PM

Sortable date on page from 3 seperate columns?
 
Is this possible to do?

I have a table that contains the following columns in it:

Month
Day
Year

The output on the page is:

December 15 2023
December 21 2023
December 02 2023

Is there a way that I can sort that data, if I'm pulling the date itself from 3 seperate columns using 3 echo statements?

Or, a better way to include the date in form input to put it into the sql table itself making it sortable?

sarettah 11-26-2022 08:33 PM

Quote:

Originally Posted by Publisher Bucks (Post 23066068)
Is this possible to do?

I have a table that contains the following columns in it:

Month
Day
Year

The output on the page is:

December 15 2023
December 21 2023
December 02 2023

Is there a way that I can sort that data, if I'm pulling the date itself from 3 seperate columns using 3 echo statements?

Or, a better way to include the date in form input to put it into the sql table itself making it sortable?

Why do you have the dates split into month, day and year? And why 3 separate echo statements?

Anyway, you can concatenate the 3 columns together to make a sortable date.

Concat function: https://www.w3schools.com/sql/func_mysql_concat.asp


.

Publisher Bucks 11-26-2022 09:03 PM

Quote:

Originally Posted by sarettah (Post 23066079)
Why do you have the dates split into month, day and year? And why 3 separate echo statements?

Anyway, you can concatenate the 3 columns together to make a sortable date.

Concat function: https://www.w3schools.com/sql/func_mysql_concat.asp


.

So that when someone uploads they can choose a specific date for publication from a drop down menu, that was honestly the only way i knew how to achieve what i wanted lol

I'll take a look at that link, thanks :)

sarettah 11-26-2022 09:10 PM

Quote:

Originally Posted by Publisher Bucks (Post 23066090)
So that when someone uploads they can choose a specific date for publication from a drop down menu, that was honestly the only way i knew how to achieve what i wanted lol

I'll take a look at that link, thanks :)

Do a pull from the database of id and concatenated date sorted by the concatenated date.

Make a dropdown using the id as the key and the concatenated date as the display value.

Then when they pick the date from the dropdown you can retrieve the data using the id.

.

Publisher Bucks 11-26-2022 09:45 PM

Quote:

Originally Posted by sarettah (Post 23066096)
Do a pull from the database of id and concatenated date sorted by the concatenated date.

Make a dropdown using the id as the key and the concatenated date as the display value.

Then when they pick the date from the dropdown you can retrieve the data using the id.

.

Awesome, thank you!

fuzebox 11-27-2022 12:03 AM

Quote:

Originally Posted by Publisher Bucks (Post 23066090)
So that when someone uploads they can choose a specific date for publication from a drop down menu, that was honestly the only way i knew how to achieve what i wanted lol

:Oh crap

sarettah 11-27-2022 08:12 AM

Quote:

Originally Posted by Publisher Bucks (Post 23066090)
So that when someone uploads they can choose a specific date for publication from a drop down menu, that was honestly the only way i knew how to achieve what i wanted lol

I re-read this this morning after Fuzebox quoted you.

Why not just use a date picker for that?

<input type="date"

https://www.w3schools.com/tags/att_input_type_date.asp


Not sure why you would have the month, year, day tabled in 3 columns if you are using the date as the publishing date for the user to pick from.

I assumed the table also had other data and you had just split your date up for some reason.

.

Publisher Bucks 11-27-2022 01:45 PM

Quote:

Originally Posted by sarettah (Post 23066200)
I
I assumed the table also had other data and you had just split your date up for some reason.

.

You assumed correctly, there are a couple of other fields in that table that relate to the document upload also.

For example, if someone is out who is supposed to publish a document, or the document doesnt pass qc, they can edit the field and set a future date.

sarettah 11-27-2022 02:33 PM

Quote:

Originally Posted by Publisher Bucks (Post 23066288)
You assumed correctly, there are a couple of other fields in that table that relate to the document upload also.

For example, if someone is out who is supposed to publish a document, or the document doesnt pass qc, they can edit the field and set a future date.

But why are you splitting your date into 3 columns? Why not just store the date?

.

Publisher Bucks 11-27-2022 05:36 PM

Quote:

Originally Posted by sarettah (Post 23066307)
But why are you splitting your date into 3 columns? Why not just store the date?

.

Because when they publish they are published on specific dates, which correlate to the writing process and publication date of previous titles.

Maybe I'm not fully understanding what you are saying about storing the date? Doesnt that just do the same thing when stored? :Oh crap

sarettah 11-27-2022 06:13 PM

Quote:

Originally Posted by Publisher Bucks (Post 23066369)
Because when they publish they are published on specific dates, which correlate to the writing process and publication date of previous titles.

Maybe I'm not fully understanding what you are saying about storing the date? Doesnt that just do the same thing when stored? :Oh crap


A date type field in the database is for storing a date. It is just one column, it does not split it into 3 pieces as you described.

Quote:

I have a table that contains the following columns in it:

Month
Day
Year
https://dev.mysql.com/doc/refman/8.0/en/datetime.html

Quote:

The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.
So you would have the publish date as a date field in the db table.

On your recipe add/edit screen you would have the date as an input field on the screen.

On an add the field would be blank and the user would enter or pick the date for publishing. On the edit field, once the record was retrieved you would have the field populated with the current publish date and the user would be able to change it.

.

Publisher Bucks 11-27-2022 10:38 PM

Quote:

Originally Posted by sarettah (Post 23066377)
On an add the field would be blank and the user would enter or pick the date for publishing. On the edit field, once the record was retrieved you would have the field populated with the current publish date and the user would be able to change it.

.

Oh okay, I see what you're saying now, okay let me have a play about, that seems like it would actually be much simpler, thank you!


All times are GMT -7. The time now is 02:10 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123