The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
Retrieving data from database - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Modifications and Hackery (https://userspice.com/forums/forumdisplay.php?fid=29)
+--- Thread: Retrieving data from database (/showthread.php?tid=1288)

Pages: 1 2 3 4 5 6 7


RE: Retrieving data from database - LBC - 01-22-2019

Hello Mudmin, I have another question Smile

I have added a column to the database named "validity". I want to add dates at which a membership card was bought in there.

There are two kinds of cards...one that is valid 6 months and one that is valid 12 months.

I was hoping there would be an echo possible in which I could specify whether the card is 6 or 12 months valid so the displayed date would be set accordingly.

So for instance, a 6 month card bought on January 1st 2019 would echo out "valid till: July 1st 2019"


RE: Retrieving data from database - mudmin - 01-22-2019

Can you give me an idea of how the date is stored in the db? Is it date or datetime?


RE: Retrieving data from database - LBC - 01-22-2019

Well, I have set it to just date right now (as an added time would be unnecessary).
So I guess the first of January 2019 will be stored as "2019-01-01

If datetime is better...than that is fine too Smile


RE: Retrieving data from database - mudmin - 01-22-2019

Nope. That's perfect.
Give me a min.


RE: Retrieving data from database - mudmin - 01-22-2019

Is that validity column in the users table of the db?


RE: Retrieving data from database - mudmin - 01-22-2019

And random question...why don't you just add 6/12 months to the date before you add it to the db?


RE: Retrieving data from database - LBC - 01-22-2019

(01-22-2019, 12:18 PM)mudmin Wrote: Is that validity column in the users table of the db?

Yes, its is.

(01-22-2019, 12:19 PM)mudmin Wrote: And random question...why don't you just add 6/12 months to the date before you add it to the db?

ehm...because then I would have to calculate it myself and an error could be made.
If the computer does it...there can be no mistake..well...theoretically


RE: Retrieving data from database - mudmin - 01-22-2019

So if you want to show 6 months from the date in the db it's
$date = date('Y-m-d', strtotime("+6 months", strtotime($user->data()->validity));
dump($date);

If you want to add the time before you put it in the db, it's...
$date = date('Y-m-d', strtotime("+6 months", strtotime(date("Y-m-d"))));
$db->update('users',$user->data()->id,['validity'=>$date]);


RE: Retrieving data from database - LBC - 01-22-2019

(01-22-2019, 12:25 PM)mudmin Wrote: So if you want to show 6 months from the date in the db it's
$date = date('Y-m-d', strtotime("+6 months", strtotime($user->data()->validity));
dump($date);

If you want to add the time before you put it in the db, it's...
$date = date('Y-m-d', strtotime("+6 months", strtotime(date("Y-m-d"))));
$db->update('users',$user->data()->id,['validity'=>$date]);

so, no echoing?


RE: Retrieving data from database - mudmin - 01-22-2019

I'm not sure I'm understanding. So you have a date in the db that is the date that the item was purchased. How do you know if it is a 6 month or 12 month one?