Posts

PHP: show a comma on all value except last value from mysql_fetch_array

$count = 0; while ($servdescarrayrow = mysql_fetch_array($servdescarray)) { if ($count++ > 0) echo ","; echo $servdescarrayrow['serv_desc']; }

PHP: Prepend leading zero before single digit number

It will only add the zero if it's less than the required number of characters. When working with numbers, you should use %d (rather than %s ), especially when there is the potential for negative numbers. If you're only using positive numbers, either option works fine. For example: sprintf("%04s", 10); returns 1000 sprintf("%04s", -10); returns 0-10 Where as: sprintf("%04d", 10); returns 1000 sprintf("%04d", -10); returns 100 <? php $num = 4 ; $num_padded = sprintf ( "%02d" , $num ); echo $num_padded ; // returns 04 ?> You can use sprintf: http://php.net/manual/en/function.sprintf.php .

WordPress: Defined Home and Site Url

WP_SITEURL , defined since WordPress Version 2.2 , allows the WordPress address (URL) to be defined. The value defined is the address where your WordPress core files reside. It should include the http:// part too. Do not put a slash " / " at the end. Setting this value in wp-config.php overrides the wp_options table value for siteurl and overrides the WordPress address (URL) field in the Administration > Settings > General panel when logging in using wp-login.php. It will _not_ update your Home url. Read more about this in depth in the link provided in the Note field: WP_HOME is another wp-config.php option added in WordPress Version 2.2 . Similar to WP_SITEURL, WP_HOME overrides the wp_options table value for home but does not change it permanently. home is the address you want people to type in their browser to reach your WordPress blog. It should include the http:// part and should not have a slash " / " at the end. If you won...

Email template: eDM SPECIFICATIONS

Image
eDM SPECIFICATIONS - Content must be supplied in HTML - email body width: 600 pixels - Total file weight (including HTML, CSS, images): 50KB - We cannot accept emails built with CSS in the header tags or that include flash or forms! - Use HTML tables for layout. Tables control the design layout and presentation. - Use Standard Inline CSS. Do not design your HTML as a web page. Most web-based email clients strip Header CSS HTML - Explicitly define colour values as email clients may have different default colours which vary from web browsers. - All image tags should include width and height attributes as stretched images will not render correctly in some email clients. - <div> tags as the box model is not supported by a majority of e-mail clients and should be avoided. Tables should be used for e-mail layout. Also, avoid using rowspan as it won’t render consistently. - It is recommended to set cellpadding and cellspacing to 0 on the table elients. - Line-breaks (<br />)...

Email preheader best practices, Preheader email marketing and email preheader html

Image
A preheader is a small section that appears at the top of your email. The following tips can help you make the most of the preheader in every marketing campaign  you develop. Understand that the first line of your text is critical . It is this text that will appear when recipients access their inboxes from smartphones, tablets and other mobile devices. Know how to code the preheader properly. The preheader should convey the message of your email clearly and concisely. Use the preheader text to summarize your offer in a way recipients can easily understand. Keep things short and simple . Your recipients are busy, and they are probably looking through dozens of new emails every time they log on to their mobile devices. Use left alignment for your preheader text. This will make the text easier to read, especially on mobile devices. Use a standard easy to read font for your preheader text. Now is not the time to get too fancy. Include a clear call to action in y...

Convert from MySQL datetime to another format with PHP

// $datetime is something like: 2014-01-31 13:05:59 $time = strtotime ( $datetimeFromMysql ); $myFormatForView = date ( " d- m-Y g:i A" , $time ); // $myFormatForView is something like: 01/31/14 1:05 PM

PHP get Google News RSS Feed

If you know how to get the HTML data from the right XML-element ( <description> in this case) you can just strip all HTML with PHP's strip_tags This seems to work like you want it: <?php $news = simplexml_load_file('http://news.google.com.kh/news?pz=1&cf=all&ned=kh&hl=en&as_scoring=r&as_maxm=4&q=html5&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss'); foreach($news->channel->item as $item) {         echo "<h1>" . $item->title . "</h1>";     echo '<p>' . strip_tags($item->description) ."</p>"; } ?>