gdata.io.handleScriptLoaded({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$georss":"http://www.georss.org/georss","xmlns$thr":"http://purl.org/syndication/thread/1.0","xmlns$blogger":"http://schemas.google.com/blogger/2008","id":{"$t":"tag:blogger.com,1999:blog-4095748245355156272"},"updated":{"$t":"2023-12-23T10:10:36.395+05:30"},"category":[{"term":"Make Money"},{"term":"Earn Tricks"},{"term":"PC Tips"},{"term":"Sundar Pichai"},{"term":"Cash"},{"term":"PayPal"},{"term":"DATABASE"},{"term":"Neal Mohan"},{"term":"internet"},{"term":"Wrong answer"},{"term":"email"},{"term":"CEO"},{"term":"boot"},{"term":"functions"},{"term":"installation process"},{"term":"Remote employees"},{"term":"facebook"},{"term":"Apache"},{"term":"data types"},{"term":"Encapsulation"},{"term":"Hosting"},{"term":"Launch"},{"term":"Website"},{"term":"microsoft"},{"term":"Maximize earning potential"},{"term":"Facebook Tips"},{"term":"whatsapp"},{"term":"Inheritance"},{"term":"google"},{"term":"Free Antivirus n key"},{"term":"Pc Tricks"},{"term":"computer"},{"term":"navbar"},{"term":"Content"},{"term":"Facebook Timeline"},{"term":"NASA"},{"term":"free"},{"term":"Object-Oriented Programming"},{"term":"Spare time"},{"term":"James Webb Space Telescope"},{"term":"tool"},{"term":"Points"},{"term":"Top Ten Antivirus 2012"},{"term":"Tasks"},{"term":"Funny Java Tricks"},{"term":"programming"},{"term":"software bundle"},{"term":"Work from home"},{"term":"Chatbot"},{"term":"Freelancing"},{"term":"Howto"},{"term":"PHP"},{"term":"youtube"},{"term":"Step-by-step guide"},{"term":"Best  Tricks"},{"term":"ChatGPT"},{"term":"Mobile app"},{"term":"Free Sms to World"},{"term":"Web Traffic"},{"term":"tricks"},{"term":"file handling"},{"term":"Best  Tips"},{"term":"Learn PHP"},{"term":"NEWS"},{"term":"XAMPP"},{"term":"LG"},{"term":"AI"},{"term":"Bard"},{"term":"Telecommuting"},{"term":"Remote work"},{"term":"Flexible work"},{"term":"Orkut Ha(k"},{"term":"Online jobs"},{"term":"leptop"},{"term":"Remote work culture"},{"term":"Videos"},{"term":"format"},{"term":"Article"},{"term":"Instagram"},{"term":"hotspot"},{"term":"Android"},{"term":"Susan Wojcicki"},{"term":"Trading"},{"term":"control structures"},{"term":"Gift cards"},{"term":"PHP applications"},{"term":"Net tips"},{"term":"MYSQL"},{"term":"Search engines"},{"term":"Earn money online"},{"term":"MariaDB"},{"term":"Market value"},{"term":"web development"},{"term":"OpenAI"},{"term":"Mobile Tips"},{"term":"gadgets"},{"term":"Net Funny Tricks"},{"term":"blog"},{"term":"web applications"},{"term":"Windows Tricks"},{"term":"wifi"},{"term":"Abstraction"},{"term":"Polymorphism"},{"term":"windows"},{"term":"Wechat"},{"term":"computer setup"},{"term":"highspeed"},{"term":"MVC"},{"term":"dynamic content"},{"term":"4GSpeed"},{"term":"Facebook Tricks"},{"term":"Safe On Facebook"},{"term":"mobile"},{"term":"Atta Pol"},{"term":"variables"},{"term":"recharge"},{"term":"SEO Tips"},{"term":"iOS"},{"term":"PHP programming"},{"term":"Mobile as a Webcam"},{"term":"Remote jobs"},{"term":"database connectivity"},{"term":"Artificial Intelligence"},{"term":"Free Call"},{"term":"Rewards"},{"term":"Surveys"},{"term":"bootable pendrive"},{"term":"Blogger Tricks"},{"term":"Orkut tips"},{"term":"FB Status Updater"},{"term":"Post"},{"term":"OOP"},{"term":"Share price"},{"term":"Extra income"},{"term":"operators"},{"term":"web server"},{"term":"bluestacks"},{"term":"PHP scripts"},{"term":"Blogger Widgets"},{"term":"Java Tricks"},{"term":"Alphabet"},{"term":"scripting language"},{"term":"Virtual work"}],"title":{"type":"text","$t":"Get Tricks - All Type of Tricks"},"subtitle":{"type":"html","$t":"The site gives knowledge and tricks about social sites, computer tricks, the Internet and earning money online. All Information and tips are in One Place."},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://www.blogger.com/feeds/4095748245355156272/posts/default/-/functions?alt\u003djson-in-script\u0026max-results\u003d5"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/4095748245355156272/posts/default/-/functions?alt\u003djson-in-script\u0026max-results\u003d5"},{"rel":"alternate","type":"text/html","href":"http://www.gettrickz.com/search/label/functions"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Juber Khan Baloch"},"uri":{"$t":"https://www.blogger.com/profile/03500557746501068520"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"generator":{"version":"7.00","uri":"https://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"1"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"5"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-4095748245355156272.post-5611209826186953795"},"published":{"$t":"2023-02-16T17:31:00.009+05:30"},"updated":{"$t":"2023-02-25T00:15:11.279+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"variables"},{"scheme":"http://www.blogger.com/atom/ns#","term":"MYSQL"},{"scheme":"http://www.blogger.com/atom/ns#","term":"database connectivity"},{"scheme":"http://www.blogger.com/atom/ns#","term":"PHP"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control structures"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Howto"},{"scheme":"http://www.blogger.com/atom/ns#","term":"dynamic content"},{"scheme":"http://www.blogger.com/atom/ns#","term":"operators"},{"scheme":"http://www.blogger.com/atom/ns#","term":"web development"},{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"},{"scheme":"http://www.blogger.com/atom/ns#","term":"programming"},{"scheme":"http://www.blogger.com/atom/ns#","term":"file handling"},{"scheme":"http://www.blogger.com/atom/ns#","term":"data types"},{"scheme":"http://www.blogger.com/atom/ns#","term":"web applications"}],"title":{"type":"text","$t":" Start Learn PHP/MYSQL : How to Do PHP Development and MySQL Database Connectivity A Complete Guide for Beginners"},"content":{"type":"html","$t":"\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\u003ca href\u003d\"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghL5eKZrCu_YChm0F8odjOM92UJVahPJMXZdllX4sDDnnGVzfSU1OAYaQpzI4UadAIXab9A6HXGYvg8-cUKQS4G2btOZ-1b4Al6VHbt-a-ZDxhJCSgDLHT3Ew-C46pgBYyYiNDRgo1oH8TdkGeUzmHKMW64ePpE5l7gi32ZiGShc-E4pd8kQJQsiyz4Q/s1024/A-Comprehensive-Guide-to-the-Basics-of-Web-Development-and-Database-Connectivity-for-Beginners.jpg\" style\u003d\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003e\u003cimg alt\u003d\"A-Comprehensive-Guide-to-the-Basics-of-Web-Development-and-Database-Connectivity-for-Beginners\" border\u003d\"0\" data-original-height\u003d\"683\" data-original-width\u003d\"1024\" height\u003d\"213\" src\u003d\"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghL5eKZrCu_YChm0F8odjOM92UJVahPJMXZdllX4sDDnnGVzfSU1OAYaQpzI4UadAIXab9A6HXGYvg8-cUKQS4G2btOZ-1b4Al6VHbt-a-ZDxhJCSgDLHT3Ew-C46pgBYyYiNDRgo1oH8TdkGeUzmHKMW64ePpE5l7gi32ZiGShc-E4pd8kQJQsiyz4Q/w320-h213/A-Comprehensive-Guide-to-the-Basics-of-Web-Development-and-Database-Connectivity-for-Beginners.jpg\" title\u003d\"A-Comprehensive-Guide-to-the-Basics-of-Web-Development-and-Database-Connectivity-for-Beginners\" width\u003d\"320\" /\u003e\u003c/a\u003e\u003c/div\u003e\u003cp\u003e If you are interested in building web applications and working with databases but do not know where to start you have come to the right place. In our previous articles we have covered topics like\u003ca href\u003d\"https://www.gettrickz.com/2020/01/start-learn-phpmysql-start-using-php-in.html\" target\u003d\"_blank\"\u003ePHP and MySQL setup for Windows and Linux OS\u003c/a\u003e. Today we will dive into the basics of \u003ca href\u003d\"https://www.gettrickz.com/2016/04/start-learn-php-what-is-php-how-to.html\" target\u003d\"_blank\"\u003ePHP\u003c/a\u003e. As a powerful and versatile programming language, PHP is widely used for developing dynamic web applications, handling files and connecting to databases.By mastering its fundamentals you can take your web development skills to the next level.\n\u003c/p\u003e\u003cp\u003e\nIn this guide we will focus specifically on the basics of PHP web development and database connectivity. From variables and data types to operators, control structures and functions we will cover everything you need to know to get started with PHP.With real world examples and best practices we will guide you through the process of connecting PHP to a database and working with common database operations like reading, writing and updating data.\u003c/p\u003e\n\u003cp\u003e\nWhether you are a beginner or have some experience with other programming languages this guide will provide a solid foundation for building your skills in PHP and developing your own web applications.So let's Get started and learn the basics of web development and database connectivity in PHP to become a proficient web developer .\u003c/p\u003e\n\u003ch3\u003e\u003cu\u003eHere are some of the basics of PHP:\u003c/u\u003e\u003c/h3\u003e\n\u003col\u003e\u003cli\u003e\u003cb\u003eSyntax:\u003c/b\u003e PHP code is typically embedded within HTML, using opening and closing tags respectively. PHP statements end with a semicolon (;).\n  \u003c/li\u003e\u003cli\u003e\u003cb\u003e\nVariables: \u003c/b\u003eIn PHP you can define variables using the $ symbol, followed by the variable name. For example, $name \u003d \"John\"; assigns the value \"John\" to the variable $name.\n\u003c/li\u003e\u003cli\u003e\u003cb\u003e\nData Types:\u003c/b\u003e PHP has various data types, including strings, integers, floats, booleans, arrays and objects.\n\u003c/li\u003e\u003cli\u003e\u003cb\u003e\nOperators:\u003c/b\u003e PHP has various operators including arithmetic (+, -, *, /, %), assignment (\u003d), comparison (\u003d\u003d, !\u003d, \u0026gt;, \u0026lt;, \u0026gt;\u003d, \u0026lt;\u003d), and logical (\u0026amp;\u0026amp;, ||, !).\n\u003c/li\u003e\u003cli\u003e\u003cb\u003e\nControl Structures:\u003c/b\u003e PHP has various control structures, including if-else statements, switch statements, while and do-while loops ,for loops and foreach loops.\n\u003c/li\u003e\u003cli\u003e\u003cb\u003e\nFunctions:\u003c/b\u003e PHP allows you to define and call functions. Functions are used to perform specific tasks and can be reused throughout your code.\n\u003c/li\u003e\u003cli\u003e\u003cb\u003e\nForms: \u003c/b\u003ePHP is commonly used in web development to process data submitted through HTML forms.\u003c/li\u003e\u003c/ol\u003e\n\u003ch4\u003e1.Syntax:\u003c/h4\u003e\n\u003cp\u003e PHP is a server side scripting language which means that the code is executed on the server before the resulting HTML is sent to the client's browser. PHP code is typically embedded within HTML using opening and closing tags respectively.Here is an example of PHP code that prints \"Hello world!\" to the screen:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n echo \"Hello world!\";  \n ?\u0026gt;  \n   \n \u0026lt;/body\u0026gt;  \n  \u0026lt;/html\u0026gt; \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cp\u003eIn Example echo statement is used to print the text  \"Hello world !\"  to the screen. \u003c/p\u003e\u003cp\u003eget started with running PHP code on your PC the first step is to run XAMPP controller .This will allow you to run PHP code on your computer/PC. Once XAMPP is running navigate to the C \u003e xampp \u003e htdocs folder on your PC. In this folder create a new folder called \"test\".Next create a new file in this folder called \"index.php\". You can open this file in a plain text editor like notepad or you can download a more advanced editor like Sublime \u0026 Visual Studio .\n\u003c/p\u003e\u003cp\u003e\nAfter opening the \"index.php\" file in your text editor copy the PHP code from above and paste it into the file. Save the file  close the editor. You re now ready to run your first PHP Code .\n\u003c/p\u003e\u003cp\u003e\nTo do this open your web browser (such as Google Chrome/ Internet Explorer)and enter the following URL in the address bar:\"localhost/test/index.php\". This will run the PHP code and display the message \"Hello world!\" in your web browser .\n\u003c/p\u003e\u003cp\u003e\nCongratulations you have successfully Run your first PHP code on your PC/Computer.With this basic setup you can now begin to learn more about PHP  and Start building your own web applications .\u003c/p\u003e\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\u003ca href\u003d\"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje2kZpIQVl3tB6KvHiam2D4xkDAdBES2_AiVDRvhrsF_CxmcJvzvpIMwIMxhajYiYxoRmoDPNpY6o-s_A0ipE5_1qtULLX9oA0XVitIF7OKyMi_K1EC6G1guxAU0XbtasmBs3Tnxl0amVYAvgcL9XO16e3x9oKGRdlFrKapKe4xLbVytIvDnVWXi-QcQ/s800/hello-world-first-php-code-run.jpg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"367\" data-original-width\u003d\"800\" height\u003d\"294\" src\u003d\"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje2kZpIQVl3tB6KvHiam2D4xkDAdBES2_AiVDRvhrsF_CxmcJvzvpIMwIMxhajYiYxoRmoDPNpY6o-s_A0ipE5_1qtULLX9oA0XVitIF7OKyMi_K1EC6G1guxAU0XbtasmBs3Tnxl0amVYAvgcL9XO16e3x9oKGRdlFrKapKe4xLbVytIvDnVWXi-QcQ/w640-h294/hello-world-first-php-code-run.jpg\" width\u003d\"640\" /\u003e\u003c/a\u003e\u003c/div\u003e\u003cbr /\u003e\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\u003cbr /\u003e\u003c/div\u003e\n\u003ch4\u003e2.Variables:\u003c/h4\u003e\nIn PHP variables re used to store values.Variables can be assigned a value using the $ symbol followed by the variable name . Example :\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $name \u003d \"John\";  \n $age \u003d 30;  \n $height \u003d 1.75;  \n $is_student \u003d true;  \n ?\u0026gt;  \n     \n \u0026lt;?php echo $name; ?\u0026gt;\u0026lt;br\u0026gt;  \n \u0026lt;?php echo $age; ?\u0026gt;\u0026lt;br\u0026gt;  \n \u0026lt;?php echo $height; ?\u0026gt;\u0026lt;br\u0026gt;  \n \u0026lt;?php echo $is_student; ?\u0026gt;  \n   \n  \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;   \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003e\nIn this example four variables are defined: $name, $age, $height and $is_student. The variable $name is assigned the value \"John\" $age is assigned the value 30 $height is assigned the value 1.75 and $is_student is assigned the value true. Note that PHP is a loosely typed language, which means that the data type of a variable is determined automatically based on the value assigned to it.\u003c/p\u003e\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\u003ca href\u003d\"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf46ftGq1fkQaP8V_9gb3hRNPOH-55sTojRHcUl-IIL1bGMFomCBe6ewu8Pg0uNeuplnM2OD2DZVEWIBiN7_KVCGROp7ylff3b9P71Sny7OYlO2dFrEZp6Sf49cX43cUCB4FWli6FziC8k5dVBg2EY0OJObDmcT1meNkUZQiFylpqL8EO7gyTSy1oGdQ/s800/learn%20php%20code%20with%20gettrickz.jpg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"382\" data-original-width\u003d\"800\" height\u003d\"306\" src\u003d\"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf46ftGq1fkQaP8V_9gb3hRNPOH-55sTojRHcUl-IIL1bGMFomCBe6ewu8Pg0uNeuplnM2OD2DZVEWIBiN7_KVCGROp7ylff3b9P71Sny7OYlO2dFrEZp6Sf49cX43cUCB4FWli6FziC8k5dVBg2EY0OJObDmcT1meNkUZQiFylpqL8EO7gyTSy1oGdQ/w640-h306/learn%20php%20code%20with%20gettrickz.jpg\" width\u003d\"640\" /\u003e\u003c/a\u003e\u003c/div\u003e\u003cbr /\u003e\u003cp\u003e\u003cbr /\u003e\u003c/p\u003e\n\u003ch4\u003e3.Data Types:\u003c/h4\u003e\n\u003cstrong\u003e\u003cu\u003ePHP has several data types including:\u003c/u\u003e\u003c/strong\u003e\n\u003cul\u003e\u003cli\u003e\nStrings: a sequence of characters enclosed in quotes. Example : \"Hello world!\"\n\u003c/li\u003e\u003cli\u003e\nIntegers: whole numbers without a decimal point. Example: 42\n\u003c/li\u003e\u003cli\u003e\nFloats: numbers with a decimal point. Example: 3.14\n\u003c/li\u003e\u003cli\u003e\nBooleans: true or false. Example: true\n\u003c/li\u003e\u003cli\u003e\nArrays: a collection of values indexed by a key. Example: $colors \u003d array(\"red\", \"green\", \"blue\");\n\u003c/li\u003e\u003cli\u003e\nObjects: a complex data type that represents a realworld object. \u003c/li\u003e\u003c/ul\u003e\n\u003cstrong\u003e\u003cu\u003e\nExample:\u003c/u\u003e\u003c/strong\u003e\n\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $name \u003d \" John \";  \n $age \u003d 30;  \n ?\u0026gt;  \n     \n \u0026lt;?php echo \" Hello my name is $name and I m $age years old . \"; ?\u0026gt;  \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\u003cp\u003eIn the above code , we define two variables using PHP.$name is a string datatype and is assigned the value \"John\" while $age is an integer datatype and is assigned the value 30. Using the echo statement we print a greeting to the screen that includes the values of these variables. The output of the code will be \"Hello , my name is John and I am 30 years old\". This simple example demonstrates how to define variables and output their values using PHP.\u003c/p\u003e\n\u003ch4\u003e4.Operators:\u003c/h4\u003e\n\n\u003cstrong\u003e\u003cu\u003ePHP has several operators  including:\u003c/u\u003e\u003c/strong\u003e\n\u003cp\u003e\u003cstrong\u003e1.Arithmetic operators:\u003c/strong\u003e used to perform mathematical operations , such as addition (+), subtraction (-), multiplication (*), division (/) and modulus (%) .\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre  class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n \u0026lt;?php  \n $x \u003d 10;  \n $y \u003d 3;  \n echo $x + $y;    //Outputs 13  \n echo $x - $y; // Outputs 7  \n echo $x * $y; //Outputs 30  \n echo $x / $y; // Outputs 3.3333333333333  \n echo $x % $y; // Outputs 1  \n ?\u0026gt;  \n   \n   \n   \n \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cstrong\u003e2.Assignment operators :\u003c/strong\u003e used to assign a value to a variable . Example:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre  class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $x \u003d 10;\n $y \u003d 3;\n $x +\u003d $y;  // equivalent to  $x \u003d $x + $y;\n $x -\u003d $y;   //  equivalent to $x \u003d $x - $y;\n $x *\u003d $y; // equivalent to $x \u003d $x * $y;\n $x /\u003d $y; //  equivalent to $x \u003d $x / $y;\n $x %\u003d $y; // equivalent to $x \u003d $x % $y;\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cstrong\u003e3.Comparison operators :\u003c/strong\u003e used to compare two values . Example:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n  $x \u003d 10;  \n  $y \u003d 3;  \n  var_dump($x \u003d\u003d $y); // Outputs bool(false)  \n  var_dump($x !\u003d $y); // Outputs bool(true)  \n  var_dump($x \u0026gt; $y); // Outputs bool(true)  \n  var_dump($x \u0026lt; $y); // Outputs bool(false)  \n  var_dump($x \u0026gt;\u003d $y); // Outputs bool(true)  \n  var_dump($x \u0026lt;\u003d $y); // Outputs bool(false)  \n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cstrong\u003e4.Logical operators :\u003c/strong\u003e used to combine two or more conditions . Example:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n  $x \u003d 10;  \n $y \u003d 3;  \n $z \u003d 5;  \n var_dump($x \u0026gt; $y \u0026amp;\u0026amp; $x \u0026gt; $z); // Outputs bool(true)  \n var_dump($x \u0026gt; $y || $x \u0026lt; $z); // Outputs bool(true)  \n var_dump(!($x \u0026gt; $y)); // Outputs bool(false)   \n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003ch3\u003e5.Control Structures:\u003c/h3\u003e\n\u003cstrong\u003e\u003cu\u003e\nControl Structures In PHP  re Used to execute code based on certain conditions . \u003c/u\u003e\u003c/strong\u003e\n\u003cp\u003e\u003cstrong\u003eIf-else statements :\u003c/strong\u003e used to execute code if a certain condition is true or execute a different code if the condition is false. Example:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $x \u003d 10;\n$y \u003d 3;\nif ($x \u0026gt; $y) {\n  echo \"x is greater than y\";\n} else {\n  echo \"x is less than or equal to y\";\n}  \n\u003ci\u003e//Outputs x is greater than y\u003c/i\u003e\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cstrong\u003eSwitch statements :\u003c/strong\u003e used to execute different code blocks based on the value of a variable . Example:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n$day \u003d \"Monday\";\nswitch ($day) {\n  case \"Monday\":\n    echo \"Today is monday\";\n    break;\n  case \"Tuesday\":\n    echo \"Today is tuesday\";\n    break;\n  case \"Wednesday\":\n    echo \"Today is wednesday\";\n    break;\n  default:\n    echo \"Today is not monday, tuesday or wednesday\";\n} \n\u003ci\u003e//Outputs Today is monday\u003c/i\u003e\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cstrong\u003eLoops:\u003c/strong\u003e used to execute a block of code multiple times . Here are some examples:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n\u0026lt;?php  \n // While loop  \n $i \u003d 1;  \n while ($i \u0026lt;\u003d 10) {  \n  echo $i;  \n  $i++;  \n }  \n ?\u0026gt;  \u003ci\u003e//Outputs 12345678910\u003c/i\u003e\n \u0026lt;br\u0026gt; \u0026lt;?php  \n // Do-while loop  \n $i \u003d 1;  \n do {  \n  echo $i;  \n  $i++;  \n } while ($i \u0026lt;\u003d 10);  \n   \n // For loop  \n for ($i \u003d 1; $i \u0026lt;\u003d 10; $i++) {  \n  echo $i;  \n }  \n ?\u0026gt;  \u003ci\u003e//Outputs 1234567891012345678910\u003c/i\u003e\n \u0026lt;br\u0026gt;\u0026lt;?php  \n // Foreach loop (used to loop through arrays)  \n $colors \u003d array(\"Red\", \"Green\", \"Blue\");  \n foreach ($colors as $color) {  \n  echo $color;  \n }  \n ?\u0026gt;  \u003ci\u003e//Outputs RedGreenBlue\u003c/i\u003e\n    \n\n\n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003ch3\u003e6.Functions:\u003c/h3\u003e\n\u003cp\u003e\nFunctions in PHP are used to perform specific tasks and can be reused throughout your code. Here 's an example of a function that calculates the sum of two numbers :\u003c/p\u003e\n\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \nfunction sum($x, $y) {\n  $result \u003d $x + $y;\n  return $result;\n}\n\necho sum(2, 3); \n\n ?\u0026gt;  \u003ci\u003e// Outputs 5\u003c/i\u003e\n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eIn this example a function called 'sum ' is defined that takes two parameters $x and $y calculates their sum and returns the result using the return statement. The function is then called with the arguments 2 and 3 and the result is printed using the echo statement.\n\u003c/p\u003e\u003cp\u003e\nFunctions can also have default parameter values which are used if no value is passed in for that parameter:\u003c/p\u003e\n\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \nfunction sayHello($name \u003d \"World\") {\n  echo \"Hello, $name!\";\n}\n\nsayHello(); \nsayHello(\"John\"); \n\n ?\u0026gt;  \u003ci\u003e// Outputs \"Hello World!\"\u003c/i\u003e \n \u003ci\u003e// Outputs \"Hello John!\" \u003c/i\u003e\n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\u003cp\u003eIn this example a function called sayHello is defined that takes an optional parameter $name with a default value of \"World\" . If a value is passed in for $name that value is used , otherwise the default value is used. The function is then called twice once with no argument and once with the argument \"John\" , and the output is printed using the echo statement.\u003c/p\u003e\n\n\u003ch3\u003e7.Arrays:\u003c/h3\u003e\u003cp\u003e\nArrays in PHP are used to store multiple values in a single variable. Here 's an example of an array:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n$colors \u003d array(\"red\", \"green\", \"blue\");\necho $colors[0]; // Outputs \"red\"\necho $colors[1]; // Outputs \"green\"\necho $colors[2]; // Outputs \"blue\"\n\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eIn this example an array called $colors is defined that contains three elements . The elements are accessed using their index , which starts at 0.\u003c/p\u003e\n\u003cp\u003e\n  Arrays can also be created using the array function :\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n$ages \u003d array(\"Peter\" \u003d\u0026gt; 32, \"John\" \u003d\u0026gt; 28, \"Mary\" \u003d\u0026gt; 45);\necho $ages[\"John\"]; // Outputs 28\n\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\u003cp\u003e\nIn this example an array called $ages is defined using key-value pairs . The elements are accessed using their key which is a string .\n\u003c/p\u003e\u003cp\u003e\n  Arrays can be looped through using the foreach loop :\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n$colors \u003d array(\"red\", \"green\", \"blue\");\nforeach ($colors as $color) {\n  echo $color;\n}\n// Outputs RedGreenBlue\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eIn this example the array $colors is looped through using the foreach loop and each element is printed using the echo statement.\u003c/p\u003e\n\n\u003ch3\u003e8.File Handling:\u003c/h3\u003e\n\u003cp\u003eFile handling in PHP is used to read and write files on a server . The fopen function is used to open a file and returns a file pointer that is used to access the file. Here 's an example of reading a file: Create a new file and name it \"example.txt\".Type \"Hello World My name is Jhon\" into the file and save the file . \u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n$file \u003d fopen(\"example.txt\", \"r\");\nif ($file) {\n  while (($line \u003d fgets($file)) !\u003d\u003d false) {\n    echo $line;\n  }\n  fclose($file);\n}\n// Outputs Hello World My name  is Jhon\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\u003cp\u003e\n \nIn this example  the fopen function is used to open a file called example.txt in read mode . The while loop is used to read each line of the file using the fgets function and output it using the echo statement. Finally the fclose function is used to close the file .\n\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003cp\u003e\n  writing to a file is also possible Using the  fopen function in write mode :\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n$file \u003d fopen(\"example.txt\", \"w\");\nfwrite($file, \"Hello World!\");\nfclose($file);\n ?\u0026gt;  \n   \n   \n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003e\nIn this example, the fopen function is used to open a file called example.txt in write mode. The fwrite function is used to write the string \"Hello World!\" to the file, and the fclose function is used to close the file.\u003c/p\u003e\n\u003ch3\u003e9. Database Connectivity:\u003c/h3\u003e\n\u003cp\u003ePHP is often used for web development, and it 's common to interact with databases to store and retrieve data. PHP provides several extensions to interact with databases including MySQL and PostgreSQL.\n\u003c/p\u003e\u003cp\u003eIn a previous post about\u003ca href\u003d\"https://www.gettrickz.com/2016/05/start-learn-phpmysql-what-is-mysql-why.html\" target\u003d\"_blank\"\u003e MySQL\u003c/a\u003e, we discussed how to create a database and table. In this post we will provide a summary of those steps and explain how to create a database using phpMyAdmin .\u003c/p\u003e\u003cp\u003eIn this post we will explain how to create a database using phpMyAdmin which is a popular webbased tool for managing MySQL databases. With phpMyAdmin you can easily create and manage databases , tables and other database objects.\u003c/p\u003e\u003cp\u003eYou can create a new database by following these Steps:\u003c/p\u003e\u003col\u003e\u003cli\u003eClick on the \"New\" button in the left hand navigation menu to create a new database.\u003c/li\u003e\u003cli\u003eEnter a name for your database in the \"Create database\" form.You can choose any name you like but it ' s a good idea to choose something descriptive and easy to remember.\u003c/li\u003e\u003cli\u003eSelect the default collation for your database. This specifies the character set and sorting order that should be used for text data in your database. In most cases , you can leave this set to the default value of \"utf8_general_ci\".\u003c/li\u003e\u003cli\u003eClick the \"Create\"  button to create your new database.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eOnce you have created your database , you can start creating tables by following these steps:\u003c/p\u003e\u003col\u003e\u003cli\u003eClick on the name of the database you just created to enter it.\u003c/li\u003e\u003cli\u003eClick on the \"New\" button in the left  hand navigation menu to create a new table.\u003c/li\u003e\n  \u003cli\u003eEnter a name for your table in the \"Create table\" form. Again , it 's a good idea to choose a descriptive name that reflects the purpose of your table.\u003c/li\u003e\u003cli\u003eEnter the number of Columns you want your table to have.Each column represents a different Type of data that you want to store in the table.\u003c/li\u003e\u003cli\u003eFor each column, enter a name and select a data type. The data type determines the kind of data that can be stored in the column. For example , you might use an \"int\" data type for numeric values or a \"varchar\" data type for text strings.\u003c/li\u003e\u003cli\u003eYou can also specify additional options for each column, such as whether it should be a primary key (which uniquely identifies each row in the table), or whether it should have a default value or be set to auto-increment.\u003c/li\u003e\u003cli\u003eOnce you have defined all of your columns and their options, click the \"Save\" button to create your new table.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThat's it! You have now created a new database and table using phpMyAdmin. From here, you can start populating your table with data, running queries and managing your database in a variety of other ways.\u003c/p\u003e\n\u003cp\u003eTo create a table named \"users\" with three columns - \"id\", \"name\" and \"email\" - using phpMyAdmin, you can follow these steps:\u003c/p\u003e\n\u003col\u003e\u003cli\u003e\u003cp\u003eOpen phpMyAdmin and select the database where you want to create the \"users\" table.You can select the database by clicking on its name in the left-hand sidebar.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eClick on the \"Structure\" tab at the top of the page to create a new table.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eIn the \"Create table\" section, enter \"users\" in the \"Table name\" field.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eUnder \"Number of columns\" , enter \"3\".\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eIn the first row of the \"Column name\" column, enter \"id\".\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eIn the \"Type\" column for the \"id\" column select \"INT\" for integer.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eCheck the \"A.I.\" (Auto Increment) checkbox to make the \"id\" column an autoincrementing field.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eIn the \"Attributes\" section for the \"id\" column, select \"Primary\" to make it the primary key of the table.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eRepeat steps 5-8 for the \"name\" and \"email\" columns.\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003eClick on the \"Save\" button at the bottom of the page to create the \"users\" table with the specified columns.\u003c/p\u003e\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eThat 's it! You have now successfully created a new table named \"users\" with three columns using phpMyAdmin. You can now start populating the table with data by using the \"Insert\" tab in phpMyAdmin or by using SQL statements to insert data directly into the table.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eInsert query\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eTo insert data into the \"users\" table using SQL queries in PHP You can use The following code :\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $servername \u003d \"localhost\";  \n $username \u003d \"username\";  \n $password \u003d \"\";  \n $dbname \u003d \"myDataB\";  \n   \n // Create connection  \n $conn \u003d new mysqli($servername, $username, $password, $dbname);  \n   \n // Check connection  \n if ($conn-\u0026gt;connect_error) {  \n  die(\"Connection failed: \" . $conn-\u0026gt;connect_error);  \n }  \n   \n// Insert data into the table\n$sql \u003d \"INSERT INTO users (name, email) VALUES ('John', 'john@example.com')\";\nif ($conn-\u0026gt;query($sql) \u003d\u003d\u003d TRUE) {\n    echo \"New record created successfully\";\n} else {\n    echo \"Error: \" . $sql . \"\u003cbr /\u003e\" . $conn-\u0026gt;error;\n}\n   \n // Close connection  \n $conn-\u0026gt;close();  \n ?\u0026gt;    \n   \n   \n   \u003ci\u003e//Outputs new record created successfully\u003c/i\u003e\n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eThis  code creates a new connection to your MySQL database using the connection variables (servername, username, password, dbname), and then inserts a new record into the \"users\" table with the values \"John \" for the \"name\" column and \"john@example.com\" for the \"email\" column.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eSELECT query\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003e\n  Here 's an example of connecting to a MySQL database and executing a query:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $servername \u003d \"localhost\";  \n $username \u003d \"username\";  \n $password \u003d \"\";  \n $dbname \u003d \"myDataB\";  \n   \n // Create connection  \n $conn \u003d new mysqli($servername, $username, $password, $dbname);  \n   \n // Check connection  \n if ($conn-\u0026gt;connect_error) {  \n  die(\"Connection failed: \" . $conn-\u0026gt;connect_error);  \n }  \n   \n // Execute query  \n $sql \u003d \"SELECT * FROM users\";  \n $result \u003d $conn-\u0026gt;query($sql);  \n   \n // Output results  \n if ($result-\u0026gt;num_rows \u0026gt; 0) {  \n  while ($row \u003d $result-\u0026gt;fetch_assoc()) {  \n   echo \"Name: \" . $row[\"name\"] . \" - Email: \" . $row[\"email\"];  \n  }  \n } else {  \n  echo \"0 results\";  \n }  \n   \n // Close connection  \n $conn-\u0026gt;close();  \n ?\u0026gt;    \n   \n     \u003ci\u003e//Outputs Name: John - Email: john@example.com\u003c/i\u003e\n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eIn this Example, a connection to a MySQL database is established using the mysqli extension. The connect_error property is used to check if the connection was successful.The query method is used to execute a SQL query, and the fetch_assoc method is used to retrieve each row of the result set. Finally , the close method is used to Close the connection.\u003c/p\u003e\n\n\u003cp\u003e\u003cstrong\u003eUPDATE query\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eTo update an existing record in the \"users\" table using an SQL query in PHP  you can use the following code as an example:\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $servername \u003d \"localhost\";  \n $username \u003d \"username\";  \n $password \u003d \"\";  \n $dbname \u003d \"myDataB\";  \n   \n // Create connection  \n $conn \u003d new mysqli($servername, $username, $password, $dbname);  \n   \n // Check connection  \n if ($conn-\u0026gt;connect_error) {  \n  die(\"Connection failed: \" . $conn-\u0026gt;connect_error);  \n }  \n   \n // Update record in the table\n$sql \u003d \"UPDATE users SET name\u003d'Jane Ross', email\u003d'jane.ross@example.com' WHERE id\u003d1\";\nif ($conn-\u0026gt;query($sql) \u003d\u003d\u003d TRUE) {\n    echo \"Record updated successfully\";\n} else {\n    echo \"Error updating record: \" . $conn-\u0026gt;error;\n}\n   \n // Close connection  \n $conn-\u0026gt;close();  \n ?\u0026gt;    \n   \n     \u003ci\u003e//Outputs record updated successfully\u003c/i\u003e\n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eIn this Example , the code connects to the MySQL database using the connection variables (servername, username, password , dbname)  and then updates the record with an \"id\" value of 1 in the \"users\" table to set the \"name\" to \"Jane Ross\" and The \"email\" to \"jane.ross@example.com\" .\n\u003c/p\u003e\u003cp\u003e\nYou can modify the sql query to update different records in the table with different values.You can use various SQL operators and conditions to specify which records you want to update. For Example , you can use the WHERE clause to Specify a condition that must be met for the record to be updated .\u003c/p\u003e\n\n\u003cp\u003e\u003cstrong\u003eDELETE query\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eTo delete a record from the \"users\" table using an SQL query in PHP  you can use the following code as an example :\u003c/p\u003e\n\u003cdiv class\u003d\" clsviewer \"\u003e\n  \u003cdiv class\u003d\" clsheader \"\u003e\n    \u003ci class\u003d\" languagecls \"\u003ePHP \u003c/i\u003e\n  \u003c/div\u003e\n  \u003cpre class\u003d\" ccontentclss\"\u003e\u003ccode\u003e  \u0026lt;!DOCTYPE html\u0026gt;  \n \u0026lt;html\u0026gt;  \n \u0026lt;body\u0026gt;  \n   \n \u0026lt;?php  \n $servername \u003d \"localhost\";  \n $username \u003d \"username\";  \n $password \u003d \"\";  \n $dbname \u003d \"myDataB\";  \n   \n // Create connection  \n $conn \u003d new mysqli($servername, $username, $password, $dbname);  \n   \n // Check connection  \n if ($conn-\u0026gt;connect_error) {  \n  die(\"Connection failed: \" . $conn-\u0026gt;connect_error);  \n }  \n   \n // Delete record from the table\n$sql \u003d \"DELETE FROM users WHERE id\u003d1\";\nif ($conn-\u0026gt;query($sql) \u003d\u003d\u003d TRUE) {\n    echo \"Record deleted successfully\";\n} else {\n    echo \"Error deleting record: \" . $conn-\u0026gt;error;\n}\n // Close connection  \n $conn-\u0026gt;close();  \n ?\u0026gt;    \n   \n     \u003ci\u003e//Outputs record deleted successfully\u003c/i\u003e\n   \n   \n \u0026lt;/body\u0026gt;  \n \u0026lt;/html\u0026gt;  \u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\u003cp\u003eIn this Example , the code connects to the MySQL database using the connection variables (servername, username, password , dbname), and then deletes the record with an \"id\" value of 1 from the \"users\" table.\n\u003c/p\u003e\u003cp\u003e\nYou can modify the SQL query to delete different records from the table based on different conditions. For example  you can use the WHERE clause to specify a condition that must be met for the record to be deleted .\u003c/p\u003e\n\n\u003cp\u003e\nPHP is a versatile programming language used for web development, file handling and database connectivity. With a solid understanding of the basics covered in this article, you'll be well on your way to building web applications and working with databases in PHP.The next post promises to be an exciting one as we delve into the world of object-oriented programming (OOP) in PHP. With this , you can expect to gain a deeper understanding of PHP and MySQL and be better equipped to develop small applications. OOP is an essential programming concept that makes code more organized, easier to maintain, and helps reduce errors. So be sure to tune in for the next post to enhance your PHP development skills and take your coding abilities to the next level.\u003c/p\u003e"},"link":[{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/4095748245355156272/posts/default/5611209826186953795"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/4095748245355156272/posts/default/5611209826186953795"},{"rel":"alternate","type":"text/html","href":"https://www.gettrickz.com/2020/01/start-learn-phpmysql-how-to-code-in-php.html","title":" Start Learn PHP/MYSQL : How to Do PHP Development and MySQL Database Connectivity A Complete Guide for Beginners"}],"author":[{"name":{"$t":"Juber Khan Baloch"},"uri":{"$t":"https://www.blogger.com/profile/03500557746501068520"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghL5eKZrCu_YChm0F8odjOM92UJVahPJMXZdllX4sDDnnGVzfSU1OAYaQpzI4UadAIXab9A6HXGYvg8-cUKQS4G2btOZ-1b4Al6VHbt-a-ZDxhJCSgDLHT3Ew-C46pgBYyYiNDRgo1oH8TdkGeUzmHKMW64ePpE5l7gi32ZiGShc-E4pd8kQJQsiyz4Q/s72-w320-c-h213/A-Comprehensive-Guide-to-the-Basics-of-Web-Development-and-Database-Connectivity-for-Beginners.jpg","height":"72","width":"72"}}]}});