The following warnings occurred: | ||||||||||||||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
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) |
RE: Retrieving data from database - LBC - 01-22-2019 Hello Mudmin, I have another question 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 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 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? |