Posts

PHP MySQL Database tutorial

Image
      Using PHP with MySQL In this blog, you are going to learn how PHP communicates with MySQL databases. It is common for every web developer to design a database and develop the code to manage data in the database. Once a database is created, you need to do several operations on it such as creating tables, inserting data and updating and deleting and so on. PHP has its own built-in functions to work on data that is stored in a database . The below code examples explains how to perform each operation using PHP. This tutorial requires knowledge of SQL queries. if no idea on SQL, please visit:  Learn SQL Queries Part1 .  In this tutorial, we are not using any front-end coding. Using only PHP and Database in order to keep the logic simple and straightforward.  Table of Contents: PHP MySQL - CREATE PHP MySQL - READ PHP MySQL - INSERT PHP MySQL - UPDATE PHP MySQL - DELETE   Managing MySQL Database in PHP To work with MySQL Database, PHP provide...

PHP Date Functions

Image
      Dealing with Date and Time in PHP   In this article we discuss some widely used date functions in PHP. Table of Contents  date()  getdate()  strftime()  time()  maketime()      **All dates only works when you run PHP in server.** 1. date () Function in PHP     The inbuilt PHP function date() is the most widely used method of returning date values.  date_formats.php     <?php   $today = date ( 'd-m-y' );   print $today . "<br>" ;   $today = date ( 'd m y' );   print $today . "<br>" ;   $today = date ( 'd~m~y' );   print $today . "<br>" ;   $today = date ( 'D M Y' );   print $today . "<br>" ;   ?>     output:    27-09-21 27 09 21 27~09~21 Mon Sep 2021 Time: *** Current time depends on the timezone set in Apache.  Timezone can be set as follows: date_default_timezone_set ( 'Asia/Kolk...

Cookies in PHP

Image
How to use cookies in PHP   Table of Contents What is Cookie? Creating Cookie How to View Cookies? Retrieving Cookie Removing Cookie   What is Cookie? Basically a cookie used to store client data. The website identifies a user with this data.   A cookie is a small variable that the server embeds on the user's computer.   When a page request comes from the user, the server also sends a cookie to the browser along the page URL.   Using PHP, we can create and retrieve cookie values.      PHP Cookies: Cookie is a super global variable. It is an  associative array and stores user information in the form of name value pairs.  Cookie information available to all pages on the website. Creating Cookie: Syntax : setcookie(cookie_name, cookie_ value, expire) setcookie( cookie_name , cookie_ value , expire, path, domain);   Example : setcookie( "user" , "Shashankh" , time ()+ 3600 ); expiration time is set to 1hour. current time plus 3600 ...