Book Image

Beginning PHP

By : David Carr, Markus Gray
Book Image

Beginning PHP

By: David Carr, Markus Gray

Overview of this book

<p>PHP is the preferred server-side scripting language for tech giants such as Facebook, Wikipedia, and Tumblr despite full-stack JavaScript gaining popularity with upcoming developers. This is because PHP performs better when dealing with heavy computations on the back end. In this book, you’ll learn everything you need to get up and running with the latest version of PHP, including package management with tools such as composer, secure database operations, and a whole host of other best practices that will help you stay a step ahead of traditional programmers. </p><p> </p><p></p>
Table of Contents (12 chapters)
Beginning PHP
Contributors
Preface
Free Chapter
1
Getting Started with PHP
2
Arrays and Loops
Index

Comments, Joins, and Date Formatting


In this section, we will learn:

  • How to build a comment system

  • How to join data stored in two different tables

  • How to format dates

The system as it is currently built can be improved. This can be done by building a comment feature so that a user can log activity against a contact.

They may want to note that they called the contact on Monday and was asked to call them again on Friday. Users may be working together to call a list of contacts, and it would be useful to know who made that comment and when.

Another way the system can be improved is ensuring that the dates and times are displayed in an easy-to-read format. The database table stores such information in a way that is not so human-friendly.

When creating comments, it is essential to create joins. There is almost an unlimited amount of comments that a user can post against a contact.

It would be impossible to cater for this when building the contacts field, and the comments would have to be limited. There...