MySQL: INSERT INTO … SELECT … FROM … Selectively on Table Columns / Fields to Combine Multiple Tables into One

While you can always fulfill tasks such as creating a new table out of existing ones in MySQL by the help of PHP, it’d be much faster and way more efficient with native SQL queries. Consider when you need to combine a few tables into one, more precisely, you need just certain fields / columns …

MySQL: INSERT INTO … SELECT … FROM … Selectively on Table Columns / Fields to Combine Multiple Tables into One Read More »

DreamHost Review: Pros and Cons plus Uptime Charts

I’ve been DreamHost since 2006 and that’s more than 3 years of hosting experience with them on a shared plan ($9.95 / month). For those who’d prefer scanning instead of reading, I’ll sum up my points in short lists: Pros Affordable price with generous offerings in disk storage and monthly transfer. Full pack of features …

DreamHost Review: Pros and Cons plus Uptime Charts Read More »

MySQL: Insert if doesn’t exist otherwise update the existing row

A good practice of increasing SQL efficiency is to reduce the number of separate queries as much as possible. In a situation where you want a row updated if it exists and inserted if it doesn’t may take a newbie MySQL developer to write 2 independent queries, namely: first, check if the row exists with …

MySQL: Insert if doesn’t exist otherwise update the existing row Read More »

What is a programming framework?

Programmers write programs for users so certain processes in the workflow can be automated for efficiency and correctness. As such, to improve the programming efficiency of similar projects for addressing a common set of related problems, such as the need for content management system in web authoring, some programmers write programming frameworks to integrate the …

What is a programming framework? Read More »

VeriSign Data Analyzer — The Most Authoritative Type-in Traffic Analysis Tool for Unregistered Domains / Misspelled Domains

VeriSign, the central registry for COM domains, recently released a new tool called Data Analyzer. Data Analyzer allows you to check the amount of traffic a domain name gets, even if the domain does not exist. So just the kind of traffic analysis tool that examines the type-in traffic of unregistered domains (.COM). Well, not …

VeriSign Data Analyzer — The Most Authoritative Type-in Traffic Analysis Tool for Unregistered Domains / Misspelled Domains Read More »

Katrina Costedio Steals (KatrinaCostedio.com)

Katrina Costedio currently lives in Sarasota, Florida and has a small design firm (katrinacostedio.com) that attends to small business needs doing all kinds of design work: print design, card design, logo design and web design. She’s planning to go to San Francisco, California, though. I worked for her on 2 projects, namely maahs acupuncture clinic …

Katrina Costedio Steals (KatrinaCostedio.com) Read More »

MySQL: Add Statistics Column for the Number Count of Records from Another Table

It’s hard to describe this scenario precisely with limited title length. Basically, this is when you want to dedicate a field in ‘category‘ table to store the number of articles or posts in ‘post‘ table that fall into this category. Previously, you had both ‘category’ table to store post categories and ‘post’ table to store …

MySQL: Add Statistics Column for the Number Count of Records from Another Table Read More »

PHP: Convert between Numerical Bases | Binary Number, Decimal Number, Octal Number and Hexadecimal Number Conversions

Different number notations for different numerical bases: 0144 // base 8 100 // base 10 0x64 // base 16 To convert between number bases, use PHP base_convert() function: $hex = ‘a1’; // hexadecimal number (base 16) $decimal = base_convert($hex, 16, 10); // $hex converted from base 16 to base 10 and $decimal is now 161 …

PHP: Convert between Numerical Bases | Binary Number, Decimal Number, Octal Number and Hexadecimal Number Conversions Read More »

PHP: Convert Degrees to Radians and Convert Radians to Degrees

Degrees and radians are different metric means to gauge an angle. They are mutually convertible in PHP. Simply use the PHP degrees to radians function deg2rad() and PHP radians to degrees function rad2deg(). $degrees = 180; $radians = deg2rad($degrees); // 3.1416 $degrees = rad2deg($radians); // 180 Because trigonometric calculations are usually done in radians, you …

PHP: Convert Degrees to Radians and Convert Radians to Degrees Read More »

PHP: Number Format Function to Format Numbers in PHP (Integer or Float)

To display numbers to end users, especially large numbers, you may need to format them to be more user friendly. For example, with a large integer 43386000.75, it is usually preferred to comma-separate every 3 digits to this: 43,386,000.75 To format numbers this way in PHP, you need number_format() function: print number_format(43386000.75); // prints ‘43,386,000.75’ …

PHP: Number Format Function to Format Numbers in PHP (Integer or Float) Read More »

PHP: Send HTML Email (mail)

As we all know the simplest approach to create an email message and send it out is to use the php mail() function. A typical usage example would be: mail(‘[email protected]’, ‘Subject Title’, ‘Message body goes here.’); However, as the mail() function sends emails in text/plain mime type by default, if you include HTML code in …

PHP: Send HTML Email (mail) Read More »

PHP: Wrap Long Lines | Insert Line Breaks into a Long String

Some strings of texts may lack necessary wraps and don’t have natural line breaks in them so that the lines are too long to read comfortably. Therefore, you want a way to insert line breaks in to the string every dozens of characters. The php function you need is wordwrap(): $s = ‘ … ‘; …

PHP: Wrap Long Lines | Insert Line Breaks into a Long String Read More »

PHP String Case: Uppercase all Letters or Lowercase all Letters in a String | Uppercase First Letter of a String | Uppercase First Letter of all Words in a String

It’s common that you need to reformat the texts in PHP and make them look a little more formal. For example, the first letter of all sentences should be uppercased, or with a title, the first letter of all words should also be made uppercase; in other situations, you may want all letters to be …

PHP String Case: Uppercase all Letters or Lowercase all Letters in a String | Uppercase First Letter of a String | Uppercase First Letter of all Words in a String Read More »

PHP: Change Tabs to Spaces and Vice Versa in String | Change Tab Sizes / Lengths in Strings

Everyone who ever dealt with formatting code in PHP string manipulations may want to switch between different tab sizes or simply change spaces to tabs or tabs to spaces in the formatted code string. The function we’ll need for these is str_replace(), the string search and replace php function. For example: Switch between tabs and …

PHP: Change Tabs to Spaces and Vice Versa in String | Change Tab Sizes / Lengths in Strings Read More »

PHP: Check if a string contains another string or substring

As a web site templating language, string processing is what PHP is good at. There’s always a chance that you need to verify and make sure if a string contains another string. For example, to check if an at sign is included in the entered email address by a visitor: if (strpos($_POST[’email’], ‘@’) !== false) …

PHP: Check if a string contains another string or substring Read More »

PHP: How to access a global variable inside a function without passing it?

Ideally, global variables outside a function can not and should not be accessed from within the function to hold up the programming modularization paradigm. However, if you really need to do this, especially in small programs, you can declare the variable again inside the function by the keyword ‘global‘ so as to use inside the …

PHP: How to access a global variable inside a function without passing it? Read More »

Scroll to Top