Posted in site documentation
4951
4:06 am, September 2, 2021
 

function to load one latest item with a start val load_latest_single_num

This is the same as load oldest item based on insdate then update the insdate to now - load_latest_single_update but it allows you to add a start number to the range, so allows you to access the 2nd, 3rd, etc... newest items. 

Actually this loads the newest item with a number range. not the oldest like the linked post. 

Good for loading feature items ordered by the insdate. 

PHP

/*
the same as load_latest_single but you can specify the range it will load.
for example, if you want to load the 2nd lates single item from the class
then add -- load_latest_single_num(1) and it will start at 1, rather than 0.
*/

    /*public*/ function load_latest_single_num($start_num) {
        $out = "";
        $db_table_name = $this->db->escapeString($this->db_table_name);
        $start_num = $this->db->escapeString($start_num);
        $sql = "select * from $db_table_name order by insdate desc limit $start_num,1";
        $result = $this->db->query($sql);
        while($row = $result->fetchArray()) {
            $this->status = "Item Loaded";
            // auto load all items from the $load_array
            foreach($this->load_array as $load_title) {
                $this->$load_title = $row[$load_title];
            }
            $this->loaded = true;
            return true;
        }
        return false;
    }

View Statistics
This Week
79
This Month
472
This Year
604

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
The problem with hoarding is you end up living off your reserves. Eventually, you’ll become stale. If you give away everything you have, you are left with nothing. This forces you to look, to be aware, to replenish. . . . Somehow the more you give away, the more comes back to you.
Paul Arden
Random CSS Property

@viewport

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
zoom (@viewport) css reference