Limit number of lines displayed in a table by wordpress (php( -
I have a table in WordPress that stays long and long.
I want to set a limit, so only the last 250 results are shown or only last 30days. Which is easy.
This code comes from the Wordpress Affiliate Manager plugin
ViewData ['Impressions']), $ this-> ViewData [' Impression Count ' ]); ? & Gt; & Lt; / P & gt; & Lt; Table class = "wide" & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Width = "25" & gt; & Lt ;? Php _e ('id', 'wpam')? & Gt; & Lt; / Th & gt; & Lt; Width = "200" & gt; & Lt ;? Php _e ('Date', 'wpam')? & Gt; & Lt; / Th & gt; & Lt; Width = "100" & gt; & Lt ;? Php _e ('creative', 'wpam')? & Gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt ;? Php _e ('Referrer', 'wpam')? & Gt; & Lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt ;? Php $ creativeNames = $ this- & gt; Visual data ['creative name']; Forex Currency ($ this- & gt; ViewData ['Impressions'] $ as Influence) {? & Gt; & Lt; Tr class = "impression" & gt; & Lt; Td> & Lt ;? Php Echo $ Impression- & gt; Impression Id? & Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php counter Date ("M / D / YH: I: S", $ Impression-> Date Crated)? & Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php echo $ creative name [$ impression- & gt; SourceCreative]? & Gt; & Lt; / Td> & Lt; Td> & Lt ;? Php Echo $ Impression- & gt; Refresh? & Gt; & Lt; / Td> & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt ;? Php if (Count! ($-This-> ViewData ['Impressions'])):? & Gt; & Lt; Div class = "daterange-form" & gt; & Lt; P & gt; & Lt ;? Php _e ('no records found for the selected date range.', 'Wpam')? & Gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt ;? Php endif; ? & Gt; Whether you should have an option on the plugin to limit the impression number. If it is not, you can limit it by sliding the array with
array_slice
, such as:& lt; Php $ creativeNames = $ this- & gt; ViewData ['CreativeNames']; $ Impressions = array_slice ($ -> [[impressions ''; viewdata '', 0, 250); Forex Currency ($ Impression $ Impressions) {? & Gt; & Lt; Tr class = "impression" & gt; & Lt ;! - Your code - & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt;
If you only need the previous 250, then you can add it with
array_reverse
:$ impression = Array_slice (array_reverse $ this-> ViewData ['Impressions']), 0, 250);
Comments
Post a Comment