Jump to content

I-AM-OBODO

Members
  • Posts

    439
  • Joined

  • Last visited

Posts posted by I-AM-OBODO

  1. To add initials in multiple places you just need to select more elements.

    var el = document.getElementById('initials');
    This is selecting an element with an id of "initials". In my example, we have <div id="initials"></div>, so this is the element that will be selected. So you can either create more elements with different ID's, and use multiple document.getElementById() calls, or, you can use a different selector such as a class selector. In that case you would just have multiple elements with the same class, and your initials would be added to each one. Here's an example of that: http://jsfiddle.net/22p32vj2/1/

     

     

    Thanks a zillion dozen times :)

  2.  

    specify interval based on N days

    mysql> SELECT '2015-01-31' + INTERVAL 7 DAY as next_pay;
    +------------+
    | next_pay   |
    +------------+
    | 2015-02-07 |
    +------------+

    or N weeks

    mysql> SELECT '2015-01-31' + INTERVAL 2 WEEK as next_pay;
    +------------+
    | next_pay   |
    +------------+
    | 2015-02-14 |
    +------------+
    

     

    Thanks a zillion dozen times. I have modified my code to use sql but i read somewhere that sql dates are not to be trusted! which is better? thanks

  3. If you select the Remember Me checkbox on login, then it should not be logging you out. The only time its done that to me is if I have cleared my cookie/history

     

    Which is? If you can send use proof of ownership (via PM) of that account we can reset the password for you. If you have not received the reset password email, then I guess our mail servers are down again.

     

    there's no way i could pm you cos it's not highlighted. i had this issue before and requinix fix it for me. my display name is Mr Chidi. thanks

  4.  

    1 ) The "%R" in the format string is causing the + sign to be output. If you don't want it, remove it.

     

    2 ) If you use DateTime object to add 1 month you risk missing a month eg

    $dt = new DateTime('2015-01-31');
    $dt->add(new DateInterval('P1M'));
    echo $dt->format('Y-m-d');  // 2015-03-03 (jumps from Jan to Mar)
    

    If you use SQL

    mysql> SELECT '2015-01-31' + INTERVAL 1 MONTH as next_pay;
    +------------+
    | next_pay   |
    +------------+
    | 2015-02-28 |
    +------------+
    

     

    the sql you suggested takes care for only when month is the pay frequency. what can be done on sql to accommodate for both bi-weekly, weekly and monthly?

     

    thanks

  5. @obodo,

     

    I'm not sure what the purpose of your code is, but it does not match reality. I'm sure there are some exceptions out there, but how you are calculating the pay periods is not what is done in the real world.

     

    Companies that pay once a month, don't set the pay periods up to be 30 days apart. They set up the payday to be on the same numerical date each month. For example, payday would be on the 5th of each month. However, they would also have rules to account for when the 5th lands on a weekend or a holiday.

     

    For paydays that are every every week, or every two weeks, those would be on the same day of the week every week (or two) with adjustments for holidays. Note that with this type of pay periods, there will be months with five paydays (for weekly) or three paydays (for bi-weekly)

     

    For paydays that are twice a month, they are set up the same as the monthly pay period. They will be on two specific dates each month (e.g. the 1st and the 15th).

     

    The logic you are using is not accurate and is more complicated than reality, IMHO.

     

    what then would you propose?

  6. You want an "onKeyUp" event on the input field, which will get whatever you typed in and place it in the table using .innerHTML.

     

    could you pls help with example cos i don't know nada on javascript.

    thanks

  7. Thanks all.

    I ended up using php date/time function instead of mysql. I have my logics right just as i stated earlier but i have two issues.

    (1) i'd like to get rid of the + sign in from of date_diff

    (2) just as scootstah noted; not all months are 30 days, there February and others that have 31 days. How do i get it so that it works for all the months.

     

    Thanks

     

    my code

     

     

     
    $pay_frequency = "Monthly";
    $first_payday = 10;
    
    //date of transaction
    $today = date('Y-m-d');
    
    if($pay_frequency == "Monthly"){
        
        $new_pay_frequency = 30;
        
    }elseif($pay_frequency == "Twice_monthly"){
        
        $new_pay_frequency = 14;
        
    }elseif($pay_frequency == "Weekly"){
        
            $new_pay_frequency = 7;    
    }
    
    // make date for current month
    $make_date =  date('Y-m-01');
    
    //payment frequency
    echo "Payment frequency: " . $new_pay_frequency ;
    echo "<br>";
    //first payday
    echo "First payday: " . $first_payday;
    echo "<br>";
    
    //add payment frequency to first payday to get next payday in days
    $next_payday =  $new_pay_frequency + $first_payday;
    echo "Next payday(in days): " . $next_payday;
    echo "<br>";
    
    //get next payday in date format
    $date = date_create($make_date);
    date_add($date, date_interval_create_from_date_string($next_payday.'days'));
    $nu = date_format($date, 'Y-m-d');
    echo "Next payday date: " . $nu;
    echo "<br>";
    
    
    // difference between date of transaction and next payday
    $datetime1 = date_create($today);
    $datetime2 = date_create($nu);
    $interval = date_diff($datetime1, $datetime2);
    echo "Date difference: ". $interval->format('%R%a days');
     
     
    
  8. hi all

    i dont know what it is called so i dont know what to goggle cos all my search result have not yielded desired result.

    i have a table and space for initials. i want so that when i type on the form field it will display on the table. just like the example used on jquery modal form

     

    thanks

  9. Rather than just adding 30 days, you should increment the month by one instead. Not every month has 30 days.

     

    Now the logic is simple - simply add one to the current month number. You'd need end-of-the-month and end-of-the-year logic. For example, if your pay day was on the 30th of January, adding one to the month would be the 30th of February - but that doesn't exist. So you'd just come down to that month's last day.

     

    ok thanks. will put your suggestion into consideration but that is not my problem just yet. i need to express next payday in dates. and mind you the payment frequency could be weekly or twice weekly.

    thanks

  10. hi all.

    having a hard time figuring this out.

    i have:

     

    Payment frequency: weekly(7days) twice-monthly(14days) monthly(30days)
    First payday: 8th
    Next payday: first payday + payment frequency

    Date of transaction: 2015-07-14 (today)

    Date difference: difference between date of transaction(today) and next payday:

    Due date ?

     

    For argument sake:

    Payment frequency = 30(Monthly)

    First payday = 8th

    Next payday = 38th ( 8th of next month)

    Date of transaction: 2015-07-14 (today)

    Date difference = 8th next month - today

     

    My problem is how to express 8th of next month in date format.

     

    Thanks

     

     

     
    $first_payday = 8;
    $today = date('Y-m-d');
     
     
    if($pay_frequency == "Monthly"){
        
        $new_pay_frequency = 30;
        
    }elseif($pay_frequency == "Twice_monthly"){
        
        $new_pay_frequency = 14;
        
    }elseif($pay_frequency == "Weekly"){
        
            $new_pay_frequency = 7;
        
    }
     
    echo "Payment frequency: " . $new_pay_frequency;
    echo "<br>";
    echo "First payday: " . $first_payday;
    echo "<br>";
    $next_payday = $new_pay_frequency + $first_payday;
    echo "Next payday: " .$next_payday;
     
    
  11. we cannot help you with what you tried unless you post what you tried.

     

    your task is simple, change each place that is producing a pagination link, of which there are several, so writing a user function may be helpful, so that it also has the id=value in the link. the method i suggested makes this general purpose and future proof. it also url-encodes the values for you in case they have any characters that are not allowed in links. the code in the linked to forum reply shows how to do this.

    thanks. will give it another shot and see.

  12. Hi.

     

    I tried to login to my account but it say i am not recognised but i am sure my password is correct. i tried to reset the password via forgot password. after filling the form no reset mail was sent to me. tried it a couple of times still no reset mail and so i had to open a new account. can my old account be retrieved back?

     

    i'd loved badly to have my account back. my username is funkyfela. i had to add 2 to the new one to differentiate with old one.

     

    thanks

  13. Hi all. my pagination does not show the info on next page?  believe the problem is that the value of  my $_GET[id] is not parse to the next page. but i dont know how to solve it.

    the error is unidentified id

     

    thanks

     

    my code

     

     

     
    $agent= $_GET['id'];
    $stmt = $pdo->prepare("SELECT surname, firstname FROM confirmed WHERE username = '$agent'");
    $stmt->execute();
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $_SESSION['ref_agent'] = $row['surname'] . " ". $row['firstname'];
     
     
    error_reporting(E_ALL & ~E_NOTICE);
        /*
            Place code to connect to your DB here.
        */
        // include your code to connect to DB.
    
        $tbl_name="processed";        //your table name
        // How many adjacent pages should be shown on each side?
        $adjacents = 5;
        
        /*
           First get total number of rows in data table.
           If you have a WHERE clause in your query, make sure you mirror it here.
        */
        
        $stmt = $pdo->prepare("SELECT COUNT(*) as num FROM $tbl_name WHERE invitee = '$agent'");
        $stmt->execute();
        $total_pages = $stmt->fetch(PDO::FETCH_ASSOC);
        $total_pages = $total_pages['num'];
        
        /* Setup vars for query. */
        $targetpage = "view-commission.php";     //your file name  (the name of this file)
        $limit = 3;                                 //how many items to show per page
        $page = $_GET['page'];
        if($page)
            $start = ($page - 1) * $limit;             //first item to display on this page
        else
            $start = 0;                                //if no page var is given, set start to 0
        
        /* Get data. */
        
        $stmt = $pdo->prepare("SELECT * FROM $tbl_name WHERE invitee = '$agent' ORDER BY date_processed DESC LIMIT $start, $limit");
        $stmt->execute();
        //$num_rows = $stmt->rowCount();
        //print "<p>$num_rows Record(s) Found.</p>";
        
        /* Setup page vars for display. */
        if ($page == 0) $page = 1;                    //if no page var is given, default to 1.
        $prev = $page - 1;                            //previous page is page - 1
        $next = $page + 1;                            //next page is page + 1
        $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.
        $lpm1 = $lastpage - 1;                        //last page minus 1
        
        /*
            Now we apply our rules and draw the pagination object.
            We're actually saving the code to a variable in case we want to draw it more than once.
        */
        $pagination = "";
        if($lastpage > 1)
        {    
            $pagination .= "<div class=\"pagination\">";
            //previous button
            if ($page > 1)
                $pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>";
            else
                $pagination.= "<span class=\"disabled\">« previous</span>";    
            
            //pages    
            if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up
            {    
                for ($counter = 1; $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<span class=\"current\">$counter</span>";
                    else
                        $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                }
            }
            elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some
            {
                //close to beginning; only hide later pages
                if($page < 1 + ($adjacents * 2))        
                {
                    for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
                    {
                        if ($counter == $page)
                            $pagination.= "<span class=\"current\">$counter</span>";
                        else
                            $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                    }
                    $pagination.= "...";
                    $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
                    $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";        
                }
                //in middle; hide some front and some back
                elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
                {
                    $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
                    $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
                    $pagination.= "...";
                    for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
                    {
                        if ($counter == $page)
                            $pagination.= "<span class=\"current\">$counter</span>";
                        else
                            $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                    }
                    $pagination.= "...";
                    $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
                    $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";        
                }
                //close to end; only hide early pages
                else
                {
                    $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
                    $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
                    $pagination.= "...";
                    for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
                    {
                        if ($counter == $page)
                            $pagination.= "<span class=\"current\">$counter</span>";
                        else
                            $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
    
                    }
                }
            }
            
            //next button
            if ($page < $counter - 1)
                $pagination.= "<a href=\"$targetpage?page=$next\">next »</a>";
            else
                $pagination.= "<span class=\"disabled\">next »</span>";
            $pagination.= "</div>\n";        
        }
     
     
    echo "<table width='100%' class='table table-striped'>";
    echo "<tr>
        <th bgcolor='#444444' align='center'><font color='#fff'> one</th>
        <th bgcolor='#444444' align='center'><font color='#fff'> two</font></th>
        <th bgcolor='#444444' align='center'><font color='#fff'> three</font></th>
    
        </tr>";
    // keeps getting the next row until there are no more to get
    while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        // Print out the contents of each row into a table
    echo "<tr><td>";
    echo $row['trans_ref'];
    echo "</td><td>";
    echo ucwords($row['payee']);
    echo "</td><td>";
    echo number_format($row['amount'],2);
    echo "</tr></td>";
    }
    echo "</table>";
     
    <?php echo $pagination ?>
     
    

     

    thanks

     

     

  14. Hi all.
    I have two tables where the username is what they have in common. i want to perform a join for both tables but i'm having problems with mysql joins.

    //to get the desire result individually i did
    
    //table one
    $stmt = $pdo->query("SELECT * FROM tableone WHERE username = '$_GET[id]'");
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $credit_score = $row['credit_score'];
    $acct_num =  $row['acct_num'];
    $acct_name = ucwords($row['surname']) ." ". ucwords($row['firstname']);
    $username = $row['username'];
    
    if($credit_score ==3){
        $bill_limits = 2000;
    }elseif($credit_score ==2){
        $bill_limits = 1000;
    }elseif($credit_score ==1){
        $bill_limits = 500;
    }
    
    //table two
    $stmt=$pdo->query("SELECT SUM(amt) as bill FROM tabletwo WHERE username = '$_GET[id]' AND relationship = 'PARENT'");
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $bill = $row['bill'];
    $service_charge_for_limits = '0.05' * $bill;
    $tax_rate_for_limits = '0.13' * $service_charge_for_limits;
    $bill_sum = $tax_rate_for_limits + $service_charge_for_limits + $bill;
    
    
    Approved Bill Limits = $<?php echo number_format($bill_limits,2); ?>
    <br>
    Bill Limits Used = $<?php  echo number_format($bill_sum,2); ?>
    <br>
    <?php $available_limits = $bill_limits - $bill_sum; ?>
    Bill Limits Available = $<?php echo number_format($available_limits,2); ?>
    
    The above gives me the correct result, but now i have another page where i want to all the clients and their corresponding available limits, used limits and approve limits form table two and other information from table one
    
    On the page i have
    
    $stmt = $pdo->prepare("SELECT * FROM tableone WHERE status = 'COMPLETED' ORDER BY id DESC LIMIT $start, $limit");
        $stmt->execute();
        $num_rows = $stmt->rowCount();
    
    echo "<table width='100%' class='table-responsive table-hover table-condensed table-striped'>";
    echo "<tr>
        <th bgcolor='#444444' align='center'><font color='#fff'>Account Number</th>
        <th bgcolor='#444444' align='center'><font color='#fff'>Subscriber's Name</font></th>
        <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th>
        <th bgcolor='#444444' align='center'><font color='#fff'>Limits ($)</font></th>
        <th bgcolor='#444444' align='center'><font color='#fff'>View Profile</font></th>
        <th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</font></th>
        </tr>";
    // keeps getting the next row until there are no more to get
    while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        // Print out the contents of each row into a table
        echo "<tr><td>";
        echo $row['acct_num'];
        echo "</td><td>";
        echo ucwords($row['surname']." ". $row['firstname']);
        echo "</td><td>";
        echo $row['username'];
        echo "</td><td>";
        $credit_score = $row['credit_score'];
        if($credit_score ==3){
        $bill_limits = 2000;
        }elseif($credit_score ==2){
        $bill_limits = 1000;
        }elseif($credit_score ==1){
        $bill_limits = 500;
        } echo number_format($bill_limits, 2);
        echo "</td><td>";
        echo "<a href='view-client-profile.php?id={$row['username']}'>view more</a>";
        echo "</td><td>";
        echo "<a href='delete-account.php?id={$row['username']}'>Delete Account</a>";
        echo "</td></tr>";
    
        //echo "</td><td>";
        //echo "<a href='settle.php?id={$row['acct_num']}'>Points</a>";
    
    }
    echo "</table>";

    How ca i join tableone and tabletwo (plus sum)

  15. something tells me that the rows between these two tables (using table names like table1, table2 doesn't provide useful context) are not related to each other using any sort of foreign key, but are two different types of data (that perhaps should all be in one table) that the OP wants to retrieve with the data for each username (which should actually be a userid) together in the result set. if so, you need to use a UNION query.

    yeah. u are right. the only relationship with both tables is the username. a table may have more info on it than the other.

     

    thanks

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.