site documentation
Posted in
6
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
30
This Month
216
This Year
0
Add Comment
Other Items in site documentation
function to load one latest item with a start val load_latest_single_num
make the view number zoom when mouse over or active
moving the hits widget into the post header and footer
for auto filled fields, need to change the text and background colours
use a list group for listing by category page [todo]
Comments Listing should be a custom list rather than using search
load the latest single item only
load oldest item based on insdate then update the insdate to now - load_latest_single_update
change this to a list group - other items
hero widget header - creates a nice looking hero item from a target uid and class
dropdown section
Latest from Code Widget
Related Search Terms
Other Categories in Code
c testing apache apps asp bat bootstrap bootstrap templates core css css grid design elements fancybox fonts foundation framework gimp git html icons ideas images javascript jquery js linux mac nginx node php php functions php simple html dom pi400 python react sections site bugs site documentation sql sqlite sublime svg templates tools virtual box webdev windows wordpress