First and Last Entry on a Page using Modulus Remainder
- Category: Personal Home Page
- Hits: 18333
This article is a quick note (so I never spend as long again) in PHP on how to determine when looping through a loop, which entry was first and which was last. This is incredibly useful for pagination.
PHP & MySQL Search Engine
- Category: Personal Home Page
- Hits: 41968
So we want to give a search engine to our users. This sounds really simple, we could try:
$search_term_esc = AddSlashes($search_term); $sql = "SELECT * FROM Content WHERE content_body LIKE '%$search_term_esc%'";Great! Few problems though, multiple terms are not supported; quotation marks and apostrophes may be an issue;
Yesterday's time in PHP
- Category: Personal Home Page
- Hits: 7941
$today=date("Y-m-d");
$yesterday = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
Outputting PHP files into different file formats
- Category: Personal Home Page
- Hits: 11478
I'm beginning a list as I've just spent an age trying to get PHP output to create a text file. Then my client showed me how she then opens the text file in Excel, so I said we could get the script to do that instead.
PHP to TXT
header('Content-Type: text/plain; charset=utf-8');
header('Content-Disposition: attachment; filename=foo.txt');
echo 'contents of file';
PHP to XLS
$export_file = "my_name.xls";
ob_end_clean();
ini_set('zlib.output_compression','Off');
header('Pragma: public');
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel;');
header("Content-type: application/x-msexcel");
header('Content-Disposition: attachment; filename="'.basename($export_file).'"');
Make bootstrap carousel responsive to swipe
- Category: Bootstrap
- Hits: 16226
A quick reminder on how to make the carousel in bootstrap compatible with touch devices like smartphones and tablets.
Why?
Feed back was that the user was unimpressed with the image slideshow. You have to tap on the left and right symbols...
How?
Some will suggest to load the jQueryMobile library but that started messing up the template layouts for me. I really like the solution (and think it should be voted best answer) put forward by Mark Shiraldi:
Page 9 of 9
Credit where Credit is Due:
Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.
Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.
Thank you for visiting and, as always, we hope this website was of some use to you!
Kind Regards,
Joel Lipman
www.joellipman.com


