The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (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.2.25 (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

I can see that from another filled in column which is called membership.
It either says 10cc or 5cc in there (10cc is 12 months, 5cc is 6 months)


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

Ok.  So it will be something like this.
However you figure out the length, it needs to wind up as a 6 or 12.
$length = 6;  

then
echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));


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

(01-22-2019, 12:41 PM)mudmin Wrote: Ok.  So it will be something like this.
However you figure out the length, it needs to wind up as a 6 or 12.
$length = 6;  

then
echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));

like this?

<?php echo date('Y-m-d', strtotime("+".$length=6." months", strtotime($user->data()->validity))); ?><


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

Can you tell me what column stores the length and what the length looks like? Is it a word? is it 6 or 12?


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

(01-22-2019, 01:04 PM)mudmin Wrote: Can you tell me what column stores the length and what the length looks like? Is it a word? is it 6 or 12?

the length is stored in the "membership" column and is either 10cc or 5cc (10 = 12 months / 5 = 6 months).
I could call it 10 or 5 also if that would be better.


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

Nope. That's fine.
if($user->data()->membership == '5cc'){
$length = 6;
}elseif($user->data()->membership =='10cc'){
$length = 6;
}
if(isset($length)){
echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));
}

I think that will do it.


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

(01-22-2019, 01:11 PM)mudmin Wrote: Nope. That's fine.
if($user->data()->membership == '5cc'){
$length = 6;
}elseif($user->data()->membership =='10cc'){
$length = 6;
}
if(isset($length)){
echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));
}

I think that will do it.

I'm afraid it doesn't display anything now. I have done it like this now:

<p><strong>Valid until:</strong>
        <?php if($user->data()->membership == '5cc'){
        $length = 6;
        }elseif($user->data()->membership =='10cc'){
        $length = 12;
        }
        if(isset($length)){
        echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));
        }?></p>


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

(01-22-2019, 01:17 PM)LBC Wrote:
(01-22-2019, 01:11 PM)mudmin Wrote: Nope. That's fine.
if($user->data()->membership == '5cc'){
$length = 6;
}elseif($user->data()->membership =='10cc'){
$length = 6;
}
if(isset($length)){
echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));
}

I think that will do it.

So this is going to show the length for the logged in user. Does your account have a membership and validity set?



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

(01-22-2019, 01:22 PM)mudmin Wrote:
(01-22-2019, 01:17 PM)LBC Wrote:
(01-22-2019, 01:11 PM)mudmin Wrote: Nope. That's fine.
if($user->data()->membership == '5cc'){
$length = 6;
}elseif($user->data()->membership =='10cc'){
$length = 6;
}
if(isset($length)){
echo date('Y-m-d', strtotime("+".$length." months", strtotime($user->data()->validity)));
}

I think that will do it.

So this is going to show the length for the logged in user. Does your account have a membership and validity set?

yes, bought a 10cc on january 20th 2019

   
I can fill that in on the admin_user form...see attachment


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

Can you paste the chunk of the form itself from the input of time through lessons left? Maybe copy the code and paste on pastebin and share the link here.