PHP Starter Kit - Complete PHP Class for Beginners | Dan Kelly | Skillshare

PHP Starter Kit - Complete PHP Class for Beginners

Dan Kelly

PHP Starter Kit - Complete PHP Class for Beginners

Dan Kelly

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
66 Lessons (7h 20m)
    • 1. Introduction

      1:47
    • 2. Install editor and local webserver

      9:46
    • 3. How to install plugins and EMMET review

      8:04
    • 4. Walk through Xampp and PhpMyAdmin

      7:05
    • 5. Section Review

      1:27
    • 6. PHP Introduction

      2:29
    • 7. Why use PHP

      2:52
    • 8. Hello World

      9:00
    • 9. PHP Mixed in with HTML

      6:43
    • 10. Working with variables

      3:44
    • 11. Conditionals Intro to IF statements

      10:18
    • 12. Conditionals - If statements (Part 2)

      9:08
    • 13. Conditionals - Changing variable values and observing IF statement behavior

      4:24
    • 14. Working with Switch statements

      9:34
    • 15. Introduction to Loops

      4:50
    • 16. Fun with the For Loop

      8:37
    • 17. Fun with Loops (Part 2)

      11:46
    • 18. The foreach Loop

      14:39
    • 19. Review the While and the Do While loop

      4:58
    • 20. Intro to Arrays

      2:55
    • 21. Regular Arrays

      4:15
    • 22. Associative Arrays

      5:02
    • 23. MultiDimensional arrays

      9:36
    • 24. Review Data types

      11:44
    • 25. Intro to Operators

      7:24
    • 26. Arithmetic Operator

      4:58
    • 27. Assignment Operator

      4:30
    • 28. Comparision Operator

      10:25
    • 29. Increment and Decrement Operators

      6:06
    • 30. Logical Operators

      7:24
    • 31. String Operators

      3:33
    • 32. Intro to Functions

      1:19
    • 33. Functions (Part 1)

      7:06
    • 34. Functions (Part 2)

      7:53
    • 35. Functions (Part 3)

      6:49
    • 36. Common built in functions (Part 1)

      8:49
    • 37. Common built in functions (Part 2)

      5:29
    • 38. Common built in functions (Part 3)

      9:24
    • 39. Intro to MySQL

      1:05
    • 40. Overview of PHPMyAdmin

      3:17
    • 41. Create your first database with PHPMyAdmin

      1:54
    • 42. How to create table and insert data

      8:26
    • 43. Deleting tables from PHPMyAdmin

      0:51
    • 44. Introduction to Building a framework

      1:39
    • 45. Creating the structure and including bootstrap template

      8:08
    • 46. Separating header and footer

      5:54
    • 47. Making a connection to MySQL database

      11:27
    • 48. Building the pages

      3:35
    • 49. Create menu database table

      6:42
    • 50. Creating dynamic menu (Part 1)

      7:40
    • 51. Creating dynamic menu (Part 2)

      7:28
    • 52. Creating dynamic menu (Part 3)

      3:02
    • 53. Changing the link url

      2:00
    • 54. Building the home page

      10:32
    • 55. Carousel Styling

      2:55
    • 56. Building A database driven products page

      6:39
    • 57. Creating the products table

      7:58
    • 58. Making the Products page dynamic

      7:47
    • 59. Creating services page

      11:52
    • 60. Create the About us page

      9:08
    • 61. Final touches on the about us page

      10:19
    • 62. Create the contact page with form (Part 1)

      11:57
    • 63. Create the contact page with form (Part 2)

      11:22
    • 64. Create the contact page with form (Part 3)

      11:45
    • 65. Finalizing the contact page

      7:40
    • 66. Conclusion

      0:52
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

26

Students

--

Projects

About This Class


This course was designed for beginners. Every journey begins with the first step. In this course we will walk through PHP one step at a time.

We will set up your environment and develop a PHP framework that you can build off of and use in the future.
You will also get some exposure to MYSQL, CSS, Bootstrap, Jquery & Ajax.

Meet Your Teacher

Teacher Profile Image

Dan Kelly

Teacher

Related Skills

Technology Web Development Php

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

phone

Transcripts

1. Introduction: Hi, my name is Dan Kelly and this is my course PHP starter kit, the most complete ultimate starter kit for learning PHP. If you're new to PHP or have a little working knowledge in this course is for you. Let me be your God and break down PHP step-by-step. And I'll will use real-world analogies to help you understand PHP, what's covered in this course. First, we will start by setting up your environment, your development environment. So you can develop a PhD will also explain the reason we use PHP as an, as an alternative to other languages. We'll also review the nets, nuts and bolts. Feed will review variables, arrays, operators and loops, functions, datatypes, conditional statements, Moscow and more will also get our hands dirty and will develop a project, will develop a database driven framework that you can build a future project, smear them. So let's take a look. This is the type of framework that we will be building together. We have here a bootstrap database driven framework that includes a dynamic new, and some elements on the page. Here, we'll also builds a product's page where the products are displayed as a result of querying the database. Next, we have a services page that has also database driven. In addition, we have a contact us page where the form is submitted to the database and all the contents are added inside the database. So what are you waiting for? Let's get started and do this. Hope to see you soon. 2. Install editor and local webserver: Hello and welcome. So the first thing we're gonna do is we're going to set up your environment, which entails setting up an editor. Or as we like to call it, an IDE, which stands for integrated development environment. We're going to install the IDE, which is called Visual Studio code, and that will allow you to actually write your HTML. So the first thing we're gonna do is we're gonna go to the address code dot Visual Studio.com forward slash download. Or of course you can google Visual Studio code. So once we go to this site, you simply click on the Windows. If you're using a Mac, you can use them. You can click on the Mac icon. So after you've clicked on that then yields, you should receive this pop-up that says, you know, you have chosen to download the, the EXE file. So you simply click on Save File. And you'll notice this up here should be displaying your progress. So when it finishes, you should see the folder like this here. So I've already downloaded it. So to save time, I'll just show you this one right here. So you double-click on it, just go through the installation is fairly simple. If you need some help with it, you know, you're more than welcome to contact me. I'll be glad to help you. So, so if we go to the main screen here, you'll see an icon that looks like this is, you know, Visual Studio code. So I click on it and it should open here. We'll be talking more about the editor soon. But I kinda just wanted to open it up and kinda show you sort of what it looks like here. And OK. So you can create a new file, you can open folders, you can do a lot of different things, but like I said, we'll come back to this. So the next thing you're gonna need is you're going to need at an actual development environment. A lot of times it's best to, or most of the time is best to develop locally. So what we're going to do is get a tool that will allow us to do that. And it's a tool called examp or exhale as different ways of saying it. So we want to go to Apache France.org forward slash index, or you can do a search for XAMPP. Xampp. So when you go to the site, OK, we go here if you have Windows or Linux or if you're on a Mac, you can click here and download, download it. So I would click home. In my case, I would click on XAMPP for Windows and you'll get another notification to download this file. So you would simply click on save. And we'll give it just a second here. As matter of fact, I think I've already downloaded it, so. We can go straight to that. Let me click on that again. And I don't think that I've installed it yet. So give me just a second here. Now I haven't installed it yet. Okay. So it's fairly simple to install it. Man. That's what I like about us, just the simplicity of the whole thing. So we double-click on XAMPP, we click on yes. And we'll give it just a second here. Okay? Okay, here it comes. So it's normally we'll get this message here. I just disregard the messages. Click on OK. Alright, and then click on next. And you can leave all these default items checked. Click Next and always select the default folder here as well. We'll click Next and click next again, and next. And then we'll go through and let it complete the installation here. Okay? This process does take a minute to to install. So it shouldn't take much longer. If you would like to pause the video, go ahead while this, while you finish installing and then come back to it. And you're also gonna see a message pop up during the installation process that says Windows Defender firewall has blocked some features of this app. So just choose allow access. That's all you have to do. And we'll give it just a second here. Okay? So next, what we wanna do is, of course choose your language, choose USA, click Save. Ok. So after you've completed the installation, you're going to see this, this box here are modal. And you'll see the two things that you need to be concerned with is Apache and MySQL. So basically what I do is just choose Start on Apache and start almost equal. So I'll start off our database and that'll start up our web server. So at this point is ready to go. That's all you have to do. Click on this again for some reason this is giving me a problem, but anyway, it doesn't normally do that. So just remember you can click on your start button here. And it's going to be listed here under example here. So lot of times I'll just drag it up to the desktop here. And when you minimize it is going to be here, and it's also going to be here. So, so anyway, So after you've installed it and you clicked on Apache and MySQL, you started both services. Then all you have to do from here is, and this is the cool part. So when you go local host, like so this is your default page for your, for your exam. So we can go into the database here. Or whenever you're developing, all you have to do is go to your C drive and you'll see the directory we installed example. I can click on it. And the number one directory here or folder that you should be interested in is the HT docs. That's sort of what we call the the web or the public folder. So you'll see an H T dogs that we have an index.html file. Well, that index.html file is exactly what you're seeing here. So we'll explain more about that later, but I kinda just wanted to show you that part. So the next thing is that we're going to need and this is completely optional. You can skip this if you'd like, but I'll, I like to install something called Notepad Plus, Plus. It's also an editor, but I use it for a lot of other things. If I just want to do a quick note or stuff like that, of course you can use Notepad or something, but I just, I just like this. So if you go to Notepad, dash plus dashed plus.org, or you can of course do a search through Google. And when you get here, you can choose Download and download again. And we'll save the file. And once you save it, just, just go through and install it. And we'll do a right quick here. All right. We'll give it just a second here. And in the stalls pretty quick as you can tell. And after you install it, it should it should come up here as it just did here. And I like I said, I like it because it makes additional tabs and just it's just easy to work with. And so, so that's what I like to do. So I just thought I'd share that. 3. How to install plugins and EMMET review: Hello there and welcome back. In this episode, we're going to review how to install plugins. And we're going to review something called emit. First we'll start with Amitabh. Basically what emit is as it provides shortcuts to create HTML and HTML elements. I will review some of them now. So I'm going to right-click here. And I'm going to choose New File, and I'm going to just name it index.html. You can name it whatever you like. And once we've created it here, the first thing I wanna do is, and you can do this as well. If you have an open is, just add an exclamation point. And you'll see these two things pop up here. But what you can do at this point is you can tap in, are just hit your tab key. And voila, it will actually create a skeleton HTML for use at which is great. The next thing that it'll do another example, let's say for example, we want to create an ordered list with some list items. So all we have to do is type in UL and then greater than symbol, and then dot Adams and dollar sign. And then times, how many ever you won't list items you all I'll choose five and hit enter or I'm sorry, tab. And let me try this again. Excuse me. Ok. This dollar sign, star five. And then Tab, there it is. So it created at an unordered list with all the list items and it listed your class here. So we could have, we could have actually lists. Let's say my class is dot, my class is my class name, dollar sign. And then five, and then tab. And it created my class 1-2-3-4-5. It actually incrementing the count as well, which is really cool. So the next thing, let's say, for example, you need to add a hyperlink. You can type in a and then colon link, and then tab. And there it goes. It'll create the actual framework for your or your structure for your hyperlink. Here. I will post an actual link to a cheat sheet that you can get all this information here. So the next thing is, let's say for example, I want to add a script SRC, which is usually what you do for JavaScript and jQuery at in the head of the document. So if I go. I taught in script here, then colon SRC, and hit tab. It will go ahead and create the skeleton for that. And you can just put in whatever you're linked to your JavaScript or jQuery file. Let's see another one. If we just want to do a basic class. Here, we can type in dot class and Tab. And it, it creates the div with the class name. And you can also do the same thing with an ID. So if we do dot id and then Tab, it creates the div with the id, which is great. And we can also do a form elements like a radio button. I can type in input and then colon radio, like so. And it creates the radio button for you. If we want to do a text area, we can type in t area like so and create the text area for you. And last but not least, if we want to create a submit button, because most of the time a form's going to have a submit button. We taught them button. And then colon, and then submit. And then there it is, created a button force and everything. So emit is really, really good for shortcuts. When you get really good at understanding how it works. Fantastic. It'll speed up your development skills tremendously. So. So the next thing I want to quickly show you is the Git, which is source control. So the first thing we wanna do is want to click on extensions and type in git here. And we're looking for a plugin called get easy. Here it is right here. We'll choose Install. And so it installed pretty quickly. We'll choose reload because it has to be reloaded to become effective. The plugin, that is, let's see, alright. So anytime that you want to get to the plugins mean you, what you can do is, is you can press control on a Windows PC Control Shift and the letter P. And then you'll, you'll notice if I type in git, you'll notice it has all the options available for that plugin. So the first thing I wanna do is I want to click on get easy and knit. And what that does is initialize get itself. And when I do that, you're going to notice this is going to pop up here with a three and reason it has a three is because I have three files that are new. So when I click on this, I don't wanna go too deep and get because it's kind of outside the scope of this section here. But I kinda just wanted to show you how to quickly set it up. And you'll also want to make sure that you install Git itself. You can go to Google and topping get and download Git and just install Git. I think you have to do that first. I will include a link to get as well. So that's kind of a review how install plugins. I mean, you can, you can go to the marketplace and you taught me anything with PHP. Or if you're doing some react work or CSS or even another one is bootstrap. So real popular framework and CSS framework. And you can, you know, install snippets. You can install a whole lot of different things pertaining to bootstrap. And you just choose Install. And again, you can do after you've installed it, you can do control shift and P. And that will bring up the menu for Bootstrap. So that kinda covers the overview of how install plug-ins. A little bit about Git and review, review of emit. The next thing we do is walk through XAMPP and PHP, my admin, and we'll see you there. 4. Walk through Xampp and PhpMyAdmin: Hello guys and welcome back. In this lecture we're going to review XAMPP or examp and PHP, my admin. If you installed it successfully in an earlier episode, then you can click on your start button. Give me a second. And when you scroll down, you'll see XAMPP or exam, and you'll see the control panel. An earlier episode I've basically said, you know, you can drag and drop that to the desktop. So you have a shortcut here. So what we're gonna do is we're going to open this up. And here is the Apache service and the MySQL service. And this is where we would start it. But I want to review one other thing. Sometimes when you have software installed on your computer, such as Skype, many times it runs off port 80, and by default, this runs off port 80. The Apache runs off port 80. So what? You may have to change your port. So it's real simple process to do that just a few steps. The first thing we need to do is we'll need to go to config here. And then we click on Apache HTTP. D cough. And that's gonna get you to the configuration file for Apache. So we scroll down until we see, oh, actually we can do a search just to control l for edit, find. And will be in listen, STN, like so. And well, actually there it is. So you'll see it says Listen port 80, so you can change that to a different port numbers. Slit doesn't conflict. If you'd like, if, if you're not having any problems, I've suggests just leaving it as it is. But if you have a problem where it doesn't want to start, it'll come out with in this area here, this, this'll turn red and still have green or something like that. And usually that's the case of just conflicting port numbers. So you can change this to port 8080 or you can change it to 90 or, or something like that. And it should be fun. So you would just do something like this. And that's the n. So that's the first thing you need to do. So the second thing you need to do is if we top in our, we do a search here and we search for local host. And we choose Find Next. We're looking for something called server name localhost right here. So you would do the same thing. So if I was changing it to ADHD, I would just put a t here. And then I'll do File Save, just like that. But there's one other step that we need to do. I won't save it because minds working fine on port 80. But the other thing that we wanna do is sometimes you have, you know, we'd have a problem. If we change the ports there and then we click on admin here, which essentially goes to the dashboard, for example. It would, it would still go to the old port. So all you would have to do in that case is click on config here. And then service import settings. And then basically change your port here from 80 to 8080 or 90, or whatever port number you'd like there and you just click, say That's all you'd have to do. Alright, so the next thing I want to quickly review is starting it up. So we click on start for pet Apache. And you'll notice it's yellow, but then screen and that's where the port numbers that you just saw here, 8443. And that is that these port numbers here. So we're also start up a MySQL. That's the actual database that you'll be using here. And so everything is working there. So all you'd have to do is click on your browser and then make sure you don't add HTTP or HTTPS, just type in localhost like that. And that's going to take you to the dashboard. But also like I said earlier, you can click on admin here and it's going to take you to the same, same place. It's just loading the default browser here, which is explore as you see, it's, it's the same as here. So, so that's about all you have to know about examp as far as starting the services and all that. So the next thing is, we're going to review as the PHP my admin. And this is actually the database portion of it where you can go in and you can set up your, your database name, your tables, and all that will go in that a little deeper later. But I kinda just wanted to quickly show you how quick, how easy it is to create a, a, a database. So if we click on New and, and I'll just put cool tests is name of my database here. And we'll choose Create. And there it is. We created a database system quickly and easily. So, so it's very easy to set up a database through here. And, and so it's always a good thing when you have a local environment and you're able to code and set up your database all on your local system, makes a world of difference. So I just kinda wanted to share those things with you. I do want to say one other thing. The only other thing that I typically use in this control panel here is I use sometimes I use shale. What I do on that is if I want to make connections straight to the database and run commands that I don't have. I don't I mean, for whatever reason, if I'm doing a MySQL DOM or something, that's a little more advanced stuff. But if I wanna do something like that, that's the only time that I would use this terminal window here. But, but those usually I'll choose start here, start there. And every now and now and again, I would use the shale. Other than that, that's all you have to do. So I kinda just wanted to share this with you. And so the next thing we're going to go over is I'm gonna review this, this entire section that we went through and then we'll be able to start on the basics of PHP. So we'll see you there. Thank you. 5. Section Review: Welcome back. And I would like to say congratulations on making it through your first section. Yeah. So the first section was set, you know, as you know, setting up your local environment. That's super important on getting this right because everything else is built off of, you know, with you being able to do any PHP development, you've got to have a local environment to do that. We're then that's kind of what we went through in this section, which included installing the editor, the local web server, how to install plugins in our editor, which is the Visio Visual Studio Code. And we also reviewed important plugin called emit that. And we also walked through exam and PHP madman. So in the next section we're going to go into the actual fundamentals of PHP. Everything from, you know, variables and you know, all the way through arrays and a whole bunch of cool things. And, and I'd also like to thank you for putting your trust in me to teach you how to set up your local environment as well as, you know, program in PHP. And again, thank you very much and so on to the next section. 6. PHP Introduction: Hey, what's up, guys? Welcome to the next lesson. This is the core, the fundamentals, the very important part of PHP. What's covered in this section? Why do we use PHP while we use it versus CSS? Html and JavaScript will also do a helloworld, which is conceptually the first step in programming. And we'll also talk about the importance of commenting and your code will be talking about mixing PHP within HTML. And by itself will also review variables, conditionals, loops, datatypes, strings, arrays, and functions. What do you need to get started? All by far, the first thing you need is a positive attitude. Because if you believe you can do this, UK and a promise, so keep a positive attitude, a can-do attitude. When we go through this course and you will be successful. You'll need your local environment setup, which we, we've done in the previous section. Also your IDE of choice, visual Code Studio, Studio code that I reviewed in the last section, or your own IDE. Reduce distractions. Maybe close your windows and, you know, close your door again into a quiet space. Soon can really take in everything. What are my goals as an instructor? I want to make this as fun as, and also as, as an insightful as possible. And I want to break this down into small chewable pieces. I don't want to show you a lot of code and expect you to figure it out. I'll want to, to go down to the core level, piece by piece by piece. So once you understand the core, you can do the rest of that code very easily. I want to also be available with questions and concerns that you may have. And I want you to reach your goal because the truth is, is if you're successful, I'm successful, so I'm, I'm dependent upon your success to make myself successful in this course. So with that being said, let's start in PHP basics. 7. Why use PHP: Hello and welcome back. I wanted to take a second to counter review. What, what is PHP and why would we use it? What is PHP? Php is considered a back-end programming language versus front-end languages such as JavaScript, HTML, CSS. All of those are used for a front end when you go to a website and you see, you know, pictures and things on, on the actual site, you're actually seeing a result of HTML, JavaScript and CSS or some other front and technologies. But backing in technologies such as PHP enables you to connect to the database and or bring in dynamic content. It started off being called personal home pages and then evolved into what is known as, as it's known today as Hypertext Preprocessor. Reasons for using PHP. Well, here's a very good reason is easy to learn. You don't have to be a rocket scientist to be able to learn PHP. You, most people can pick up on the concept's pretty quickly, especially with my Hill. It's friendly with HTML. It blends WE HTML really well. It's used to connect to the database. As I said earlier, we want to connect with PHP. It's the, kinda the middleware between the front end and your database is PHP. It has great documentation. It has a huge developer, developer community that if you're having some issues, that there's probably someone out there that's experienced the same problems that you would be experiencing and you can get help very easily. Plus PHP.net has a wonderful tons are tons of documentation. And there are sites like Facebook and Yahoo that get millions of hits. So you know, it's pretty stable. And there's tons of free open source applications that you can use that are built upon PHP such as WordPress and John Joomla, and a lot of different even e-commerce applications. So that's, that's what I like about it, is you can probably find some type of software that you use, you can use on your own site like WordPress is super, super popular this day and time. So anyway, with that being said, let's move on to our first, I'm part of coding, which is helloworld and commenting. See you there. 8. Hello World: Welcome back guys. The first thing we wanna do is open up our Visual Studio code. And we want to open up our XAMPP. If you remember from our previous lecture that we installed XAMPP and we installed our IDE, which is also known as Visual Studio Code. And our example here, we want to click on start for the Apache and which is our webserver and start and our MySQL, which is our database. So after we've done that, the next thing we wanna do is we want to click on our IDE, the Visual Studio code, and we want to go to File and then Open Folder. And then if you, if you need to, you can go to see XAMPP. Double-click on that and remember everything goes in our HT docs folder. That is what we want is considered the public folder or public directory. So when we double-click on that, anything that's in this folder is going to be displayed in your browser by typing in local host. And I'll show you what I mean. So the first thing we wanna do is we want to right click here and choose new and choose folder. And now list. Let's just name it my underscore project, like so. And then we choose it here and we'll click on Select Folder. And now we're actually inside of that directory. Give me just a second here. Okay, come on. Come on. It's just taken a second. Okay. Alright, so the first thing we wanna do, or rather the next thing we wanna do is we want to create a file called index dot PHP. And how we do that as we go to, you can go file new here or I prefer just to right-click here and choose New File. And I'm going to name an index dot PHP, like so. And soon as it displays, okay, so now we are, we have created an index.html file. One other thing I wanted to mention when you write PHP for it to, to actually work, it cannot be dot HTML, meaning that I can't do new file and type in, let's say start dot HTML and write PHP inside there, it won't work. So you have to remember the extension has to be dot PHP in order for this to work. So I'm just going to delete Start dot HTML here because we don't need that. Right-click and choose. See if I can get work here. Delete. Are you sure? Yes, definitely. Get out of here. Alright. So. I guess it's going to take a second and having a little bit of a problem. Alright, so the next thing is we got to remember anytime that you have an a PHP page, 80 PHP first has to have an opening and closing tag. And, and all that is, is less than symbol on your keyboard. A question mark, and then PHP, like so. And then to close it, just hit the Enter key a few times just to give us some space and put a question mark and then greater than sign. So basically the way it works, anything that's NBA between the opening and closing tag will be what the PHP engine Pretty much pretty much runs. So one other thing I wanted to mention here though, before we do that, and I'll take this back out. And remember from our earlier lecture that we use to emit, which means we want to embed HTML within, I'm sorry, PHP within HTML. So what we need to do is on the screen or in your editor, put just an exclamation point and then hit tab. And that will create all of our bare-bones, our skeleton HTML. So what we wanna do is inside the body that open and close body tag, this is where we're going to add our PHP. So what we do is same thing as before. We do a less than symbol, the question mark PHP, which is our opening tag. And then we put a few spaces here or hit the Enter key a few times, and then put the question mark greater than. And so we're going to start with just simply rotting helloworld. So you can never just type this and between just anything in-between the PHP tags because it doesn't know what to do. It's different than how you would normally do an HTML page. And that would be sufficient or okay, in an HTML page. But we're, we're actually writing PHP. So in order to have anything display on the page, we have to do echo. You can do print or echo. Most of the time it's just echo. So if you write echo, and then we won't. This is considered a string which will review strings later. Put Chair double-quotes here, and list type in some HTML, which is, we'll just do a paragraph tag, like so. And then we'll do the closing paragraph tag and we'll write hello world. Okay? And at the end of all PHP code, you have to put a semicolon, okay? And that should be all we have to do. So if we save this and we open up our browser and we type in localhost. And then forward slash. My project. I remember we named our page index dot HTML. So there we go. So it actually displays hello world. So if you right-click and review the source here, you'll see that it shows all of our HTML and you'll notice it's spitting out HTML. It's not displaying the PHP code, which is very cool. So also in addition to this, I want to quickly show you how to comment. There's a couple of ways to comment on, is really important to comment in your code. So what I do if, if you do single line comments, well, you may be familiar with this. If, if you're, if you do HTML, the comments for HTML looks like this. Okay? And you close that HTML comment. Unfortunately, that won't work within PHP. So when then PHP, there's multi-line comments and they're single line Communists. So for the single line comments, all you have to do is to forward slashes just like this. Okay? And, and that's the signal. Now, if you wanted to do multiple line, then you can do forward slash and an ass trick. And then anything. I'll multiple lines like so. Then we top in there. You'll notice it's highlighted is green, that's in the editor. That's, that pretty much tells you it's a comment. So and then you can put an asterisk and then a forward slash, and that is your closing part of your comment tag. So there's the single line which is right here. And then there's the multi, multiline which is here. And that's pretty much how you do, you know commiting. So what we reviewed was basically how to do a Hello World page that actually displays here. Let's see, and let's go back to localhost and would display the hello world here. And we also reviewed commenting, this is actually your first step. Congratulations. 9. PHP Mixed in with HTML: Welcome back. In this lecture we're going to review PHP mixed in with HTML and stand along. Okay, so let's get started. So as you see from the last lecture, we basically wrote some PHP within HTML, as you can see here, all this here is considered the HTML, as well as this down here. And everything. Starting with the Open PHP tag to the closing PH to PHP tag is considered PHP. So what we wanna do now is we actually want to separate the code. And you'll see this and a lot of, a lot of projects that when you create a project that you really want to separate, like the header, the footer and the body, and things like that. You can imagine if you had, let's say 20 pages and you had a navigation across the top that May have common navigation elements such as home Contact Us About Us Services, et cetera. And you had that on all the pages. Imagine if you didn't separate the, the code, the header, and the footer that you, if you just copied this, all this HTML as it is, and put it on all the pages and then went back and had to add an additional navigation atom. Like, you know, you wanted to create a new page and have a link to that new page, that it would, it would be a big hassle to do so. So that's why we separate the code. So that's what we're gonna do now. So if you have your editor, if you do not have your editor open, please open it now. And anyway, so in here we're going to right-click and I'm gonna choose new file. And we're going to name it header dot PHP. And we're going to create another file. So right-click choose new file, and let's name it footer dot PHP. And in the index, let's grab all this code here, all the way from the top here to the opening body tag. And let's right-click and choose cut. And let's go in the header and less, just simply do right-click paste and save it. You can do File Save or I do just control S to save it. And let's go back to the index. And let's grab this closing body tag and the closing HTML tag and right-click copy out, I'm sorry, cut. And then go to the footer and right-click Paste. Ok. And let's say that I did Control S on my keyboard. If you have a Windows PC, and I think it's Command S on the Mac. And so let's go back to the index. And let's clean this up a little bit less. Remove this. And let's remove all of this. All right, and let's put, let's just put something in here. I'll just put some of them just so you can see that. It's actually going to change. So let's bring this PHP up here. And then underneath that, we're going to introduce you to something new. This is called an include. And basically what it does is a building in PHP function that will bring in external pages. So will top in include. And let's open parenthesis here. And let's put double-quotes and less type in header HDA, the IARC dot PHP. And remember an all at the end of PHP statement, we have to do semicolon like so. And let's copy this. And let's go and we're still want to stay within the PHP closing tag, like so. And let's name this. Wow, excuse me. Let's name this footer. That already have it here. Okay, fuller dot PHP. And we're gonna save it. So we're going to come here and reload. And you'll see this is what we have. Here are what we typed in. So if we right-click and we choose View Selection source, I'm sorry, I didn't mean to, to do that. View page source. Alright, and you'll see all the HTML, HTML and everything there. So it makes it very easy to separate out, separate out the code. So we could actually create another file here. And let's name it, test dot PHP. Alright? And in this test.py PHP, all we have to do if you go to index, you could, you could actually do this. You could copy all this and go to test. And I'm doing a control V or you can right-click and choose Paste and to test page, alright, and which you saved there. And we go back to here and rewrite. Do test dot PHP. And you'll see it has test page. And anytime we make a change to the header or the footer, it's going to appear on all the pages that we've created, which would be the index and the test it will go, it will display in those pages because we've now separated the code. So hope you guys under understood this. If you have any questions or anything, by all means, let me know. And again, I wanna thank you for making it this far, so far. And and like I said, if you need anything, just let me know. I'd be glad to help you any way I can. Alright, and so now we'll move on to the next lecture and we'll be reviewing variables. I'm really excited about it. Alright, so let's move on. Thank you. 10. Working with variables: Welcome back. In this lecture we're going to review a variables. So what's a variable? Okay, let me go ahead and warn you now that you're going to think I'm crazy when I present my analogy, but this is how it works for me and this is kinda how I started understanding, you know, what, what's available, what is it exactly? So I think it I think of it as a an egg with a chick. The egg is considered the place holder. Okay, that would be your dollar sign variable name, and the chick would be the value. The variable. Does. Does the variable have rules? Absolutely. Just like everything in life has some type of rule. So does variables. So what are the rules for variables? A variable always starts with a dollar sign. For example, dollar sign myVar is a variable name. Number to. A variable must start with a letter and, or an underscore, or an underscore. Basically, number three, a variable cannot start with a number. Number for a variable can only contain alphanumeric characters and underscores a through Z, 0 through nine, or and underscore itself. Number five, variable names are case sensitive. Test var is different than test var with capital T, capital V. So now let's go back to our editor. So go ahead and open up your editor. And let's go back to that and we'll continue where we left off and the last line. Ok, so we have our editor here. And let me jot that down. Alright, so the first thing we wanna do, let's put dollar sign Book. Which would be essentially and my analogy it would be the variable name equals PHP for dummies for example. That's the actual book name. And the, if the book dollar psalm book represents the egg, then PHP for dummies, which is the value, represents the chick. So if we come down here to echo and we just type dollar sign book. And I'm going to review more on the double-quotes and single quotes in here, but for now we'll just go with it like this. And we click on File and Save. Or I do Control S. And we go to the following address, localhost my project. And we hit reload. And you'll see it says Hello World PHP for dummies. So that's kind of how it displays the value of the variable. So you can, you can run a whole bunch of code and you can insert that variable as many times within the code and it will always give you the value here, which is essentially the chick in our case. So I hope you understand this and as always, if you have any questions, please let me know. Next. We'll move on to conditionals. Thank you very much. 11. Conditionals Intro to IF statements: Welcome back. In this lecture we're going to be reviewing conditionals. So what is a conditional? When I'm teaching, I like to use live situations as a metaphor. I think it, it, it provides a connection. So you can understand better. A conditional is just making a decision in your code that will result in a true or false outcome. And basically it's an if statement. So if you will go ahead and open up your editor, if you don't already have an open. The first thing we wanna do is in-between in your index.html file, anything that's in between the two include statements, your header and footer. Just highlight everything here and choose delete. So we have an empty space there. The first thing I want to show you is if statements. So if statement looks like this, we just hop in if open parentheses, closed parentheses, open curly bracket, closed curly bracket, and then I hit Enter. Typically this is this default if statement. What it looks like. So what I wanna do now is just review the if statement. What I like to do, typically, like I said earlier, is I like to show, you know, alive situation. So in this case where we want to show an if statement and buying a house. So the first thing in this whole scenario is, does the applicant have a job? Yes or no? No. Does not have a job? Yes. Did the applicant complete alone application? No. Not completed an application? If yes, then we're gonna do a check to see if the applicant meets the income requirement. If know, the loneliest denied. If yes. And then we're going to check the credit and if his credit score of 700, that in this in my code here, I made 700 the the minimum that the applicant should should have. So also I did you know also the 60 thousand is what the applicant should should be making per year to qualify for this loan. So the way this chart reads is basically yes, he has he if he's made 60 thousand, yes. If he hasn't made 60 thousand, he actually has another option. He can put at least $10 thousand down. And if he if he puts that down, then it he will get a yes and I'll go down to check his credit score. And if it's credit score is not at least 700, he's going to be the NADH alone or yes. And the loan is approved. And so we're going to actually run out the code for this. Alright, so let's bring up our editor here. Well, the first thing we're gonna do is we're going to declare our variables. So the first thing we wanna do is write how Job is our first variable. Equals. And let's put yes. So remember this is, I'll be reviewing strings later, but this in double quotes. So this is the variable and this is the value. Alright, so the next thing we want to do, another one, app completed equals one. So we're just defining all the values through the scenario and we'll go through and play around with these and you can see how it's going to change in our code. So the next one is income. Okay? And we'll make this 50 thousand likes. So remember, you don't have to put single quotes or double quotes if it's, if it's an integer or a number. Okay? And the next thing is downpayment. Let's put an underscore between here. Okay. Alright. And let's make it, I don't know, 20 thousand. And you don't have to put commas in this either. It's best not to. On the next thing, let's go down unless put. Credit score is our variable, and we'll just put 17 here. Okay? So the next thing is we're going to start our if statements. So let's do just like we've done our default if statement. If open parentheses, close parentheses, open curly brace, close curly brace. So all we have to do in here is the first one. We were checking to see if he has a job. So you can just copy this and add it in here. Like so. Okay. And we want to do a test to see if he has a job or not, right? So we wanna make sure that he has a job in is equal to yes. Okay. And I've already to save time, I've kind of already made an echo statement here, which I will display. The code, will attach it to the course so you can see. But, but I'll show you what I have here. So basically, if if he has a job, then I'm going to echo out. And this is going to be a checkmark, a green checkmark, and with the height and width here of 20. And lyse and go back to here. And then it's applicant has a job is going to be the value. Okay? So we're going to let me remove this space. And we're also going to do an else. So when we add an else on here, so we're basically checking if it's true. Just display on the screen that via the echo statement. Display on the screen and check mark with applicant has a job else. All we have to do for adults is very easy. We can just add here. And then we do a, another opening curly, that close curly bracket like SF. And I'm going to choose the code here that I've already written. So echo, and then I'm doing another image, but this one's gonna be a read x here and it says, does not have a job is what's going to echo, echo out on the screen. Alright? So basically will make some comments in here. The a job like so. Alright, so the next check is going to, it's always good to comment in your code, as we talked about in previous lectures. Said the, now I'm going to make another comment. Okay, so now we're going to check to see if the application has been approved. So what we do is do our basic if statement here. Likes up and we'll just copy the next variable. I hope you can kind of see what we're doing here is we're essentially defining the variable and then we're putting that variable and if statement and we're just doing a check. So if App completed equals, equals one, and I need to put to each double equals. So let me, let me explain something right quick. If you have just one equal, that's an assignment operator is one is called. So it's basically assigning this value to that variable. If you do two equal sides, is called a comparison operator or where you're comparing this with this to as a, as a check to see if that is is, is what you're expecting. So, so remember that's, this. Here is the assignment operator and this is a comparison operator with a two. Just remember always put two equals here. Alright? So I'm gonna go here and I've already written it out here, like so. Okay. And same thing. We're going to add. We're going to add an else here. Like so. And I've already written the code to save time. And you can pause the video and, and get the code if you'd like, n-type it. And actually prefer that you do because a lot of times it helps a lot when you, when you type along with me. So it kinda gives you a better exposure as opposed to just watching the video. So, alright, so now we've done a check for applicant. And we've done a check for applicant if the applicant has a job. And we've also check to see if if the application has been completed. I said approved, completed. So I think we're running a little over on this video, so we're going to go on to the next one and we'll complete the rest of the if statements. See you in the next episode. 12. Conditionals - If statements (Part 2): Okay, let's continue with our if statement. Alright, so the next thing we wanna do is we want to check, does the applicant make at least $60 thousand or have a downpayment greater than, say, 10 thousand. So we'll comment that here. Right? At least 60 K k, or how a down payment greater than 10,010 K will just fit like that. Alright, so let's do our default if structure here. Like as before. And next we'll go down to income. And we'll grab that variable here. We'll add it in here, like so. And we'll do a check because we said here make it at least 60 thousand. So, so we're going to use something new called a greater than or equal. So this means is the income greater than or equal to 60 thousand blacks owed. Alright? And so, like I said, to save time, I've got and echoed here. Like so. And so if it is greater than or equal to 60 thousand is going to do a green checkmark. And it's gonna say at applicant meets income requirements. And then we need to do something called an else if here. And we need to open up some parentheses. It's a little different but, but almost the same as just doing that. If we just do an else if. And this, the reason we're doing this is because as you see here, does does the applicant's income income meet the $60 thousand requirement? If it doesn't, He has another option. If he has to put at least $10 thousand down. So that's kinda why I am doing in else if statement. If else if statement, that's what it's called. So we need to do downpayment. Here. Now payment is greater than or equal to 110 thousand, right? And, and then I have this echo statement here. Like so. Alright, and then we, it always ends with an else. So even though we can have, we could have had multiple else if statements here, and we can have as many as we want. It's going to look ugly after a while, but we can have as many as we want. But to end it, you have to do else here. And it doesn't require the open and closed parentheses. Alright, so let's go here. Else, and we're going to echo out. The following. Applicant does not meet the income requirements. Alright. And let's add the last one here. The last chick. No, actually there's two ticks. So we're going to do a credit check. We're gonna comment, I'll spell it. Kind of check. The minimum amount to pass a credit check is 700 K. And we're gonna do another if like so. And we're going to go up here, and we're going to do copy this here, like this. And we're going to drop that in here. Again. We're defining the variables. Here are declaring the variables. And then we do an if statement for each individual one. So I hope you kinda following along and kinda understand what we're doing here. Alright, so if the credit score is greater than, I'd put that in here, is greater than or equal to 17. Echo. The applicant has met the score requirements here basically. And then Else, Like so. This C and I will paste this. Else. He does not meet the credit score and minimal requirement. All right, so let's move on to the next one. This one's going to be an overall check to determine if the loan is approved or not. Okay? Again, nouns do our if statement. With open parentheses, closed parentheses, open curly brace, close curly brace is get rid of this space. When you get to coding, you, you, you don't like a certain space is, and it's, it's funny to watch from developer, developer to see what developers like, don't like. Alright, so this is going to be a little more complex here. But I'll show you what I've got here. Let me copy and paste this again to save time. Just a second here. All right, Here's what I'm doing. I'm checking all the individual variables to see if, if they match the minimum requirements. Here it's, it's basically think of it as an overall check. So I'm sad and I'm I have here does the applicant have a job? Yes. And and I'm also check in. Is the application completed? Yes. I know we did it up here, but we're this is for specificly displaying if the loan is approved or not. And I'll show you this soon. Let me take this out. Ok. So have job yes. And Apple, is the application completed? Is it equal to one? Which means yes, we just set it as a number as opposed to, you know, rotting S. And and the reason you'll notice here, I've wrapped the two checks here in open parenthesis and close parenthesis. The reason I did that is because this is kinda going to be a combination check. So I'm basically saying, is the income greater than or equal to 60 thousand, or is the downpayment greater than or equal to 10 thousand? So the reason I did that, you can't just do it. And because if you do an ant, this logic here breaks a four determinant, the loan is approved. I hope I haven't explained in that right. Because again, in our in our scenario here, we're checking to see if the income meets the requirement of 60 thousand. And we're also doing a check to see if he has at least a $10 thousand down payment. So that's essentially what I'm doing here. And if you put it in parentheses, that kinda oscillates it from the rest. That's kinda how it look at it. And credit score is greater than or equal to 700. Alright, so we're going to echo out. If it is, if all of this evaluates to true, then I want to echo out, you know, a green check mark and loan approved. If it does not, if you get a failure in any of those, then I want it to I want to echo out that it has the loan has been declined. So again, running out of time. So I want to continue on with the next lecture. We're going to continue and play around with some of these numbers and see how the if statements work. I think, I think you're really going to enjoy this. Alright, I'll see you in the next episode. 13. Conditionals - Changing variable values and observing IF statement behavior: Hey, welcome back guys. Alright, so in this episode are lecture, we're going to actually test our code to see how it functions here. So what I'd like for you to do is open up your browser, go to localhost, my project. And by the way, makes sure that your XAMPP makes sure you've opened it up and you've clicked Start on Apache and MySQL. Not that we need Moscow right now, but we'll start it anyway. It's just habit. Ok, so after you've done that in, you loaded up the the my project and page here in the browser. You should see this with all green checks. So now we're going to test it to see. So the first thing we're gonna do is remember, when we in this first if statement, we're checking to see if the applicant has a job. So if we choose No here, and we save and we hit refresh, you'll notice the red X comes up. The applicant does not have a job, therefore, the loan is denied. You've gotta have money to afford them the home. So so I'll just back this up. Yes. Alright, so the next thing is we're going to just put a 0 here, has been completed and we're gonna save and hit refresh. So the application I should have been application failed or was not submitted or something filled out here. That, but nevertheless, it's basically putting a read x here and alone is denied. Remember all this for this loan denied all this down here at the bottom is what's controlling this? Ok. So the next thing, let me change this back to one and we'll refresh. And I saved it in refreshed. Alright, so what do you think's going to happen if we changed this income to something like 2 thousand, what do you think it's going to happen? Is he's still going to be approved for along? Yes, though. Okay. Let's refresh and see. He is going to be because we have this else if else if statement. So he's going to get the loan because he has low-income, but he has a big down payment. So what happens if we change this huge down payment of 20 thousand? Maybe we'll change it to a 100 bucks. What do you think's going to happen now? Alright, let's see. I applicant does not meet the income requirements, therefore, his loan has been denied. So less changes back. See, Save. And so far he's going to get the loan. Alright, so what happens if his credit score, it drops below that 700 threshold? So let's do, let's say he's got a really bad credit score of 200. That's really bad, right? We save and refresh. He did not meet the credit score criteria or requirement and as long as been denied. So as you see, the changes you make in the variables at the top, make a direct impact in our if statement. How it's, how it's all fits together. So I would encourage you to play around with this some more to get an idea of how it works and fully understand it. And and again, you can contact me if you have any questions. But I hope you're getting a good grasp on conditionals. But I'm going to add on to this and the next lecture. I want to add something called a switch statement. So, so what we're gonna do is what if we want to? Well, I'll, I'll just wait until the next lecture. Let's move on to the next lecture and I'll go over switch statements. Okay? Alright, thanks. 14. Working with Switch statements: Welcome back. In this lecture we're going to review switch statements. And basically a switch statement is used to perform different actions based on different conditions. And how does it differ from say and if, if statement I switch statement is like an if else statement. Remember we were talking about in the income requirement here. We didn't else if imagine if we had another else if under here to check to see if the downpayment is say, greater than 11 thousand. And we had another LCF to to check to see if the downpayment is greater than 12 thousand. Imagine having, you know, ten or 15 of these to check force for specific range. It could kinda look kind of, you know, kinda bad after awhile. So what most people do is they resort to the switch statement. It looks a little cleaner and works a little better. So, so let's, let's go ahead and work with the switch statement, Add the switch. So the first thing we have to do is switch statement is of course add the word switch. Like so. We do open parentheses, close parentheses, same as the if statement, open bracket, closed bracket. You kinda see, see the similarities there. Alright, so the first thing we wanna do is we wanna take this income variable and we're going to put it in here. So what I'm gonna do, and I'll go and put a comment here. I want to display the level of and we're gonna do high, medium, low, average, or high income. So let's see. So the next thing we do is we do, we have something called a case here. Okay, we do case, and then we do another open and close parentheses. And then this is a little different. We add at the end of it, we add a colon, like so. So to save time, I've already written this out, so I will, I will paste this in here and just explain here what's going on. As a matter of fact, I'll do the whole thing so to save time. So let me go through here and just paste this whole thing. Like so. Okay. So let me explain what's going on here. So we're basically taken this value, the income, and we're checking. Now this is the first case here. We're checking to see if the income is greater or equal to 0 and if the income is less than or equal to 10 thousand, so basically we're going from 0 to 10 thousand. If, if it is, we're going to echoed user has a low income, and then we're going to actually list the income value here. And I know if you see this and you, and you've done a lot of HTML, CSS, you gotta, you gotta see this is old font color. We wouldn't use that. We'd probably put it in a deal and all that, but I was just trying to save time. So that's why I did font colors and bold tags, which is pretty much obsolete now. But if you want to, if you want to create a style sheet and add the style for that model means, you know, help you self are, go for it. Alright, so, so the next case is basically just incremented by one. So we're looking for anything that's between 10,001 to 5 thousand is what we're looking for. And if, if it falls in that range, the user has an average income. And then if neither one of those apply, say for example, it's above 5 thousand, then we're going to display green text as opposed this was green text and this is red text here. We're going to display a green text. It says user has high income. And we're also going to give him a little star here. So you'll see this here. And also I'll post this code here so you can, you can copy and work with it. Now that I'm retired, Min Bao means you get a chance to pause the video, type it out because that's the best way to learn. Alright, so I'm gonna go in here and aren't you save? And then I'm going to open up my browser back up and I'm going to refresh. And notice this appeared here is because we probably have a break here. Let's go back to here. Applicant meets income. Let's take this out. This break here, and this break here. All right, and let's use save. And let's open it back up. And there it is. User has low, has low income, and then it shows the amount. So if we go back up to the top and let me move it over. And let's put let's put let's give him a big raise. Unless let's go up to 90 thousand. And he's making some good money. Unless save. And let's openness, backup and watch. Wow. He has, the user has a high income and 90 thousand and he gets his star here. Yeah, good job. Alright, so, so that's how we would use a switch statement to do multiple, multiple outcomes based on them at the variable here. Alright, so I want to add one more switch statement here. And I'm going to copy and paste this again to save time. And I would suggest maybe. I'm viewing the code, downloaded the code within the lecture, or you can go ahead and type it out. So you can, again, you know, the more you type, the more you practice, practice makes perfect. So, so we're also gonna do the same thing with the level of income here. Well, wait a minute. That's saying give me a second here. 1 second here. Actually. I had a sea change that credit score. Like so. Alright, so this is gonna do the same thing. So essentially what you can do also is you can copy this and paste it in here. And you can change the variables from income to credit underscore score. And we're doing a check here. If it's greater or equal to 0, and if it's greater or less than or equal to 500 millimeter from 0 to five hundred, five hundred to 700. The 0 to 500 is a low credit score. The follow one to 700 is an average credit score and anything over that is a high credit score. So let's save it. And let's go here. And same thing does not meet credit score. Let's go take that break out. C. Yeah, let's take these breaks out here. And we'll test it right-click. Okay. And and it shows does not meet credit score and user has a low credit score. So let's, let's change the credit score appear and let's check it out. Alright, so let's, let's give him a great credit score. Let's do 800. Yes, pretty nice. Alright, and let's refresh. So what we should see is green and says, Yep, and user has a high credit score of 800. And again, another star. Yeah. And as long has been successfully approved. So anyway, also go back and play around with the code. And, you know, you can add other if statements if you'd like, as well as other switch statements and, you know, and give it a try. So that concludes our conditionals. I hope you understood everything that I was able to, to present to you. And as always, if you have any questions or if I can help, all means, please let me know. I appreciate your time and thank you for making it this far. And next we'll be reviewing loops. Thank you very much. 15. Introduction to Loops: Hello there and welcome back. In this lecture we're going to review something called loops. So what is a loop? The basically a loop is something used in PHP to execute the same block of code a specified number of times. So what does that mean? Basically, as, as a programmer, you as a programmer can actually write a loop to loop through items so many times to maybe echoes some value or something that you can control how many times that it loops through. Oftentimes it's maybe a true or false condition. It will continuously loop through and do whatever you need it to do until the condition of our evaluates to true, for example. So the first loop we're going to review, and by the way, there's four loops and PHP, there's the for loop, the while loop, the do while loop, and the for each loop. And we will review all four loops. But the first one I'm gonna review is called the for-loop. And it basically looks like this. We always start out with four FOR, excuse me, FOR and where open parentheses, close parentheses, open curly brace, close curly brace. That is the skeleton for a for loop. So for what goes in here, what I like to do, or how I remember it is base, basically I write t, i, that's the acronym. And so what does that stand for? Well, so the I stands for initialize. The T stands for Test, and the OS stands for increment. In C. There we go. So, so with this in mind, always remember this ITI and you can remember what goes in here. So, so to initialize, we're going to do a dollar sign i and then equals 0. So we're basically saying, okay, I is equal to 0. So we're initializing it this point. So it's always, always separated by a semicolon. Next we're going to do i again because that, by the way, that I could be anything I could, I could call that cat if I wanted to. And I can do this cat if I wanted to, really doesn't matter, but we'll leave it as i. So the next thing is, the next part would be test. So we're going to test it. So i is less than five, so we're testing the value of i and i and seeing if it's less than five. So the next part, let's do a semicolon is increment. Increment is always dollar sign whatever variable in this case it will be I and do plus, plus. There's two things which we're going to review this a little more later, but there's two things. There's called increment and decrement. Decrement is two dashes and increment as two plus signs. So essentially what this is saying is saying in this for loop where initial, initializing it to 0, we're testing it to make sure that it's less than five. So essentially what it's gonna do is it's going to loop one time. That's going to, that's going to say, oh, is it equal or less than five? Yes, it is. Go again. Is it less than five? Yes, it is. Again, isn't less than five? Yes, it is. I'll on and on until it reaches five. When it reaches five. And by the way, this increment is actually incremented every time that it's not, that it's less than five, it's going to increment it and then when it reaches five is going to stop. And that's pretty much the bare bones of for loop. That's, that's it. That's all there is to it. So what I'm gonna do is I'm going to stop the lecture here. And then the next lecture, we're going to actually build a dice again with the four loop. So you can kind of see and we can practice together and build a cool little dice game. So, okay, well, we'll see you in the next lecture. Thank you. 16. Fun with the For Loop: Hello and welcome back. In this lecture, we're going to have some fun. We're going to build a dice game. And the dice game is going to be reviewing some of the things we've learned in previous lectures, such as variables and foreloop. So the first thing we wanna do is in our editor here, we want to right-click here a, we don't choose New File. And we're going to type in not dice dot PHP. All right, and let's open up the PHP tag. And let's, let's do a closing PHP tag. So the first thing we'll do is we'll want to, I'll make a comment here. We want to declare our variable, variables and we're going to grab values using the post super global. I could spell here and assign. Let's see default values. Okay, so how do we do that? So the first thing we're gonna do is put it into a variable called Roles and equal. Just leave it there for a second. And we're going to do dice equals. And let's do numbers or number equals. Okay, let's go back to roles. Now. We're going to use something called It is set. And that basically is checking to see if the variables been said or not. Let's use it often. Let's do dollar sign underscore post. This is considered a super, super global. And we're gonna do rolls like this. And we're gonna do a shortcut for an if statement. And we learned that we add the question mark. And I'll explain this in a moment. I'll do a dollar sign underscore post or another super global. And we're gonna do rolls. Let's do a colon and TN. So what does this do one. So basically when the form is submitted, its kinda check to see if anything's been submitted in post variable called roles. If not, we're going to assign the value of ten to this, to this variable. So let's copy this. And let's paste it in here. And let's paste it in here. And let's name this dice. And this dice. Can you guess what we need to put here? That's right. Number. C, number. Okay, and let's change this value to six. And let's change this one to, let's say three could be anything from 11 through six. Okay, so that's the first part. So we're actually wrote the code to actually grab what's being submitted through the form. Well, the next part is going to be the form. So as you know from HTML lists, open up Form here. Method equals post, because this post is why we use post here. Now if this would have been good, we wouldn't use a kit super global, but in our case is supposed usually when you're submitting something that you're pushing our submitting data to the actual server you'd use post. So action equals open parenthesis C, or open double-quotes. Let's do, let's see PHP. Here. We're going to use something called, we'll use another so super global called server. Like so. And let's do PHP itself. Okay? Alright, so let me explain this and this. Let me, me do this first. Pose it, okay, and then close that. Okay. So what we're doing is setting up a form to submit through up to the post. And our action is going to be submitted essentially to itself. I mean, yeah, we could put forward slash my project for size dies, but this is just much easier just to put server PHP self because it's going to submit to itself is kinda what it says here. So the next thing is we wanna do, we wanna do a label? And we'll do four. Was Dice here. And let's close it, and let's put number of dice. Ok. Let's close the label tag and let's do a break. Okay, underneath that we were going to have to do it. Create the field. So we'll do input type equals. Let's do text. Like, like so. And let's do ID equals dice. Less do name equals dice. And let's do value equals. Okay, let's do a less than sign and most open up the PHP tagging in unless echo, dice. And semicolon has closed the PHP tag and close this. Alright, so what this is doing is basically assigning, we're creating a field called with the idea of dice and the name of dice. And the value is going to be whatever the user types in. So it's kinda, it's kinda, kinda remember what they topped down. So to make it quicker, let's just copy this. And let's here. I like to put a space between it so I can kind of see what's going on. And let's do it two more times. So let's write for this one. Let's do number of rolls. And for this one, let's do your number. Say one through six, because that's typically what's all now. While Silva dice or dy by dice. All right, so let's, let's change this. Can you guess what we're going to put here or I'm sorry, here. We're going to put the roles. Okay, let's see if rolls and let's put route roles here as well. And let's put it here roles. And we do the same thing for this, but this is going to be number, c, number and number and number. Okay? Alright, so now we have all of our actual fields for our, for our dice rolls and our number that we choose. Okay, and less close the horn. Okay, so in the next lesson we're going to actually write the for-loop and all the code necessary to create two that actually runs that ice game. So we'll see you in the next lecture. 17. Fun with Loops (Part 2): Okay, now we're in part two of building are also on dice game. So in part one, we established or declared our variables here. And we also grabbed the values of the post method here, which is the rolls Dyson number. And if nothing submitted, its basically going I use the default value in our case 1063. So now we need to actually create the PHP to do all the, I guess you call it the, the guts of the whole thing. So the first thing we wanna do is wanna do an if statement here. And let's do the skeleton, which is basically like this here. And let's do another set and open another parentheses like so. And we're gonna check that super go plug the post super global. I like this. And inside of there, we want to check, submit. Let me do a single quote here. Single quote here, here. And have you noticed something that haven't added the open-end PHP and the closed PHP. Okay, so here's what we're doing when, when the Submit button, which actually we need to add. So let me go here and typing button. And unless Du Tai egg type equals submit, cuz we gotta have some way to submit the form, right? Okay. And name equals summit. And must see. And let's just say roll the dice. And let's close the button. There we go. All right, so we basically, when this submit button is fired, then we want to check it here. And if it's, if it's the button has been clicked, then we're going to go ahead and run the code that's in here. So the first thing we wanna do is we want to create a variable called total hits. And we'll just make it an empty array here. And the next is we're gonna run our for loop. And remember dollar sign, i. Equals, and let's start it with one and then a semicolon. And then we'll do dollar sign i, because we're going to test here. Less than or equals less, say I'll roles. Okay? And let's see. And then we'll sign semicolon and then increment i plus, plus. Alright. And then the subspace in here, open our curly brackets here. And let's do this. Create a variable called hits equals 0, like so. And then let's do another for loop inside of here. And let's do x as the variable this time equals one K, X less than or equal to this time. We're gonna do nice. Alright? And semicolon and dollar sign X. And we're going to increment it. And let's do this. And we're gonna do an if statement in here that we're going to check the number. And we're also going to use something new called empty underscore Rand. And what that does is it basically creates a random number. It's, PHP is way of just choosing legacy data random number. All right, and let's do our opening, closing here, and let's increment the hits like seven. Okay. And let's go below the sea that run that one. I think it's right here. Let's go here and let's Right. Yes. And then let's put the hits in here and let's increment it. And we'll, let's put, let's put an at symbol in front of this because we want to suppress, because this for some reason that it gives me, it echoes out an error message even though it is not an error. So I'm just going to suppress that message for now. So let's see, actually right under here. And let's do Let's go to yeah, under here. Let's do order. This order are hits. So it will actually be, you know, in order. Okay? And we're gonna use something called k-sort. And unless k sorts are total hits. Here. Okay. Let's close that. And let's do one more for-each. And let's do a little kits. And as a key here and results. Now we haven't done enough for each yet. We gotta do that very shortly. But this is kind of a preview for that. So basically it's taken the array of total hits and we're, we're separating it back key and add the results here. So I'll show you what I mean in a second. All right. And we're going to echo, let's see your number. And whatever number we want to use the number variable. Like this. Suppose that D On the die, and thus use the key times and result as we split it here up above. Okay, and less to break and close the semicolon. And I think that's, I think that's it. Alright, so, so we're basically creating the for loops to loop through the numbers. And we're actually getting PHP to grab a random number and then increment the hits. And then we're sorting the total hits here. And we're doing another full reach to kind of spit out the numbers. Alright, so let's do save here. And let's open this up and let's go to whatever your project name was. My my project name was myProp underscore project. And let's put dice dot PHP. All right, let's see what we got. Alright. So we've got I think we're probably missing some breaks here. Yeah, we are. So let's go to the inputs. And let's put coupled breaks. Like so, let's do this, copy that. And let's put that here. And let's put that here. And let's look at it again. Ok, that's better. Alright, Notice that here. And let me open this back up. So notice that we've got 106, N3, sorry, tin, which is the rolls. The dice is six and the numbers three. That's the reason for this part. So when we roll the dice, oh, we got an error. Let's see what this area's my project, dice 35 and see, see what the problem is. It's good that we can troubleshoot this. If number equals myRand. Ok, that's the one I made. It's empty rand. I'm sorry. Okay. And let's refresh. Okay. Land 47. We've got an undefined variable alone, Forty Sevens, probably something I typed in correctly. Let's see your number. Number appear on the die ki times and result. In results roles. I don't see any name. C, key result. Hm, let's see. Yeah, I see the problem. It's got results with an S here, mom state. And that's the good news about being able to troubleshoot. It's almost save it here. And then I'm basically gonna click on here and hit enter. And let's roll the dice. Wow, there it goes. Okay, so it's basically saying there's six dice. It's tin roles. All these numbers here add up to Tn. And, and it looks like on the first two rolls it kinda 0 times the next file roles that came up once next two roles, it kinda came up to two. We can even be creative with this. We could do sunlight number dies 100 dice, and we can role a 100 times. And let's do pick another number. Let's pick five. Wow, so it actually gives us the number, how many times the number five came up and all those different roles. So I hope you learned something, this lecture and the nom. And so we also created a fun dice game. So, okay, so next we're going to review the for-each loop. Okay, we'll see you there. 18. The foreach Loop: Hi there and welcome back. I would like to thank you for making it this far in my course, and I'm hoping that you're learning and enjoying my course so far. So in this lecture we're going to review something called a for each loop on how does that differ from say, the for-loop? Well, the big difference is the for each loop is a loop specifically for arrays. I know we haven't reviewed arrays yet, but when we get to arrays, I think you'll kinda have a head start. So like I said, I call it the array loop. And, and the basis of this loop looks like this. It always, and you'll notice a pattern here. Always has the open and close parentheses and always has the open and closed curly brackets are curly braces, some people say. So. So what we have here is we have array expression and we always put the keyword as, as value. Like so. So we're taken the array here and we're converting it, we're using it, we're kind of shortening the name. So what, what do I mean by that? All right, say suffering. Say for example, this was a, it was named arrays. So I'll come in here and on top in dollar sign arrays as a singular value at array. For example. That's how it's set up to work. So what we'll do is let's, let's build some so you kinda understand, alright, so the first thing we're gonna do is remove all of this. And we have to open up or PHP tag, open a tag and our closing tag. Alright, so the first thing we're gonna do is we're going to create something called meal-plan. So I have this in blank element, just right-click and choose new file and name this meal underscore plan dot PHP. Okay? And same thing. Open up the PHP tag and we use a closing PHP tag. We'll add a little bit of space in there. And the first thing we wanna do is imagine that you want to create a meal plan or something, or maybe document what you ate for lunch, maybe on a health kick or something that you want to document, something for, for breakfast, lunch, maybe a snack and maybe dinner. Well, what we're gonna do is we're going to create an array of those mealtime as well as what you ate. And we're gonna put it in a nice actual table that the row colors vary from one row to the, to the other. All right, having said that, let's get started. The first thing we'll do is type in row. We'll declare a value. Variable called row underscore color. And we're gonna do array here. If I can spell it correctly here, open up our prints the tag, and let's put in. You can put in any colors. This is for the alternating row color, but I'm going to use like a light gray and a darker gray so that our single quotes or pound sign and put our hex colors. Color, I'm going to put E. Alpha is o. I'm sorry, 00. Two. Okay. And then I'm gonna put for the other color was which is a kind of a darker gray. I'm gonna put pound because it's a hex, C eight, C five, C five. Like So. I should have capitalizes, sees less demanded capitalize those. C. Okay, so we have our row colors here. Let's declare a variable called color underscore index. And I'll explain why we need that in just a second. Okay, now let's create our array called meal. Okay? Equals array. Like so. And we're going to choose do breakfast. And we're gonna do our arrow here. And again, I'll explain more about arrays in a later lesson. But for right now again gives you a headstart. Let's say bacon and eggs. One naught. Alright? Okay. And well actually, I didn't wanna close that yet. I just wanna do this. So in order to make it look good, kind of maybe just if I get it here. A child allotted up lacZ and see and a2, close that. Ok. And we'll choose this here and we'll do pizza. That's good. That's a good choice. All right. And again, like I said, want to line up, I always like to line up the arrows here. And let's copy this couple of times. Okay? And let's name this snack. And let's, let's try to be a little healthy. This name is Apple. And for dinner, let's, let's, we're going to still stay on that health kid. Can we earn we're just going to eat a salad. Okay, all right, so we got our array with all our different meals, mealtimes and, or what we ate at each meal. Alright, so I'm gonna do an echo statement here. And basically to save time, I'm just going to paste this and kinda explain it here. C. Alright? Okay. So basically those are, those of you that are familiar with CSS. I'm just basically do an inline style here. What this is doing is it's sintering, kinda sintering. The meal-plan in the center of the screen. You know, in actual site, I would obviously take this out and put it in its own style sheet. But to save time, I'm doing this way. So we're basically echoing out the meal plan. And you can pause the video and type all this, and I prefer that you do so. So you learn, learn a little better. So, and we're also opening our table here. And we're making the table we at 50%. And we're also aligning it. That's what's happened in here. Alright, so now let's do a foreach loop. So now we're going to kind of socle through the array. So what we put here as meal, because that is the variable that we declared for the, this hole already. So all of these values is going to be inside of meal. So we'd have to have some way to get those values out. And by the way, this is called an associative array, where has a key and a value. Ok? So for each open parentheses, put the array variable in there. And open curly brace, close curly brace. Alright, and so inside of here we're going to do an echo. And we're going to do start our table row, like so, and then do a bg color. So r equals i. So another thing we haven't went over yet, but another thing if we start this off with a double quote, we can't have another double quote inside of there. You can start off with a single quote, but I think it's a little easier just to do this. What you have to do is you have to escape this double quote. And just with a backslash in there, like some. Alright, and now we're going to top in row underscore color. Okay? I spell that right? Yep, I D it. And unless you do this index, so what's happening with this color index is, is, it's actually kind of a smart way to, to figure out which row is its own and add that color to it. So whether it's going to start out at the color index is 0. And we're going to, every time it increments, its gonna change it to one. And so it kind of changes color based on the row. That is all anyway. So go here and let's close this. And let's do echo. And this time we're going to open up a TD. And the key here. And we'll close the TED, like so. And let's see, and let's open up another Td. And this time we're going to put the value. Okay? And we're going to close the TD. And we're gonna do T, close the TR. Ok. And here. Okay. And now, let's see that something's wrong here. I think it's, it gets here. And there goes. All right, so we've got that. So next we're going to make a comment. This is W and LTCHs switches the color in the x, t, w, e, n, one and zeros. Okay? Alright, and so the last thing here, excuse me, is we're going to do a color underscore index equals one, and then we're gonna minus the color underscore index. So this is how it figures out again, which would color the row should be. And then outside of our foreach loop, we're gonna do now we're going to echo the table clothes and table tag. And here, OK. And now we have the closing table tag here. Alright, so now we can save this. And let's go to our browser. And let's change this to meal underscore plan. Okay? And we have an error. So online seven, let's see what's going on there. And let's see bacon and eggs. Oh, okay. You know what? Mom state. These are supposed to be commas sorry about that, guys. And then a C here and that we don't have, we don't need a comma and the last one. So let's go back to here. And line 15. We got we have a problem. Let's see what that is. For each o in audit and finish it off so male as key. And then our arrow. And then let's do value. Can't believe effort out there anyway. So that's the good thing about troubleshooting, right? So let's do this. Alright, so line 15. Let's see what's the problem here. So we have our foreach, we have our meal as dollar sign key. Maybe I can add that and that will probably help. Alright, let's see. All right, there we go. And now we've taken our array and we've actually created a list base and the actual rows are colour or different colours. Now you can change that to any color you like. You can, you can actually write, for example, red and green. Even though that's not going to look that nice. We'll go here and voila, it changes the color. So that's what the for-each loop is used for. It is used for cycling through the array and it actually outputting the values. So I hope you understood what we've done here. If you have any questions, as always, just let me know. Okay, so the next lecture we'll be reviewing the do-while loop. Okay, we'll see you next lecture. Thank you. 19. Review the While and the Do While loop: Welcome back. In this lecture we're going to review do-while loops and while loops, since they're so similar among just combine both of them in this one lecture. So the first thing we wanna do is we're going to right-click here and won't choose new file unless name it while dot PHP. Okay? And then we're going to open up our PHP tag. And we're going to close our PHP tag here. And we're going to declare a variable named X. And we're gonna give it a value of one. All right? And we're going to write du. And this was different from the other loops, as in it doesn't have the, the open and close parentheses. It doesn't have that. That's the only one that doesn't. But now we're going to just do open and close curly bracket. And we're going to write echo. The number is. And let's do dollar sign x here and then break. And we'll do increment x plus plus. All right, and then here is where we actually write the wow. It's the while loop inside of the dude. So we'll do dollar sign X is less than or equal to five and will go here, and that should be it. So what's happening here is where echoing the number is x amount of times, it's going to basically increment this number. So this should show so many times. And this is the increment. As long as the condition is true, x is less than five, it'll loop through. That's essentially what it does. And an added note to this, I've never used do-while loops, understand how they work, but typically most people just use the while loop. For this. The do-while is something that I don't believe many developers use. At least I don't. Okay, so we'll save this and then we'll open up our browser and we'll hit refresh. And as you see here, it has the number 12345. So it's basically echoed out, are ran five times through the loop and stopped because the six Tom is not less than five, so the loop stops. In addition to that, the while loop, like I said, is basically similar in that we still have a variable here that we've declared. And let's do this. I'm gonna keep this here, and I'm gonna go below it and do sine x. Let's do dollar sign i for this one and equals one. Okay? And will rot. Wow. Open parentheses, close parentheses, open bracket, close bracket, curly, curly bracket. And in here we'll do dollar sign i is less than or equal to five. Pretty much the same as we have here. And we'll do echo. The number is dollar sign i. And then we'll do a break like so, and close it with a semicolon. And then we'll do dollar sign i and then increment like so, and choose this. So we'll do, I'll just put echo HR tag here so you can kinda see you individually there. All right, so let's run this. You can see it does the exact same thing. That's why I said most people just use the while loop. Not necessarily to do all its just a little extra effort for the same thing. Just doesn't seem like work, seem like it's worth it to me. So But anyway, I hope you understood this and now we'll be moving on to the next lecture. Thank you for your time. 20. Intro to Arrays: Hello there and welcome back. In this lecture we're going to be reviewing something called arrays. So what the heck is an array? I think of the array is as sort of like a postman. The postman would be the array and the letters and the packages would be considered the values of the array. So the, the postman is the actual container. The, and then like I said, the letters and packages would be the values. What tops of arrays are there? There's regular array, which is the first one, also known as indexed or numerical re. An example would be if we had a variable called cars. And in the variable was an array with the values of Volvo, BMW, and Toyota. They can be referenced by the actual position, I guess you'd call it cars 0 because in programming, everything starts with 0. So cars one would be here, horse two would be here. And then the next one is called an associative array is also known as the keys are a is what I call it. So we have the variable cars, which is the array, and Ford. And we have the arrow symbol, or some people call it Rockets symbol. And this is the value. So the Ford as a blue collar Chevys, Toyota is the green BMW is read. And they can be referenced like this. As soon as you referenced the cars variable with Ford, the value is going to it's going to split the value of blue Chevy. It's going to split the value of black. Bmw. It's going to spit out the value of red. And our next, our next array is called a multidimensional array, also known as the scary array. What does a scary word mean? Don't worry. It's only means that it's an array. Inside of array, you can have as many arrays as you want inside of an array, and it's called multidimensional an example. So we have, I think of this whole lack apparent array. And then you have aren't opening array. And then you have all the different arrays listed within this array. That's all a multidimensional array. And it sounds scary, has a very scary name, but it's not really that scary if you think about it. It's just like I said, array within arrays. So let's review all the different arrays in the next lectures. Thank you. 21. Regular Arrays: Okay, let's review the regular array. Alright, so the first thing I want you to do is open up your IDE and make sure your exam, you're XAMPP is working. Make sure here that both of these were run in, and it will be highlighted in green as you see here. If they're both running, if not, just open it up and choose start for each, open up your IDE. Next week, we're going to right-click and choose New File and topped in array. Let's do array one dot PHP. Okay? And what's the first thing we do? We open up our PHP tags, right? And do a couple of spaces, knew the closing PHP tag. Alright, so let's do this. First thing. Let's do a dollar sign cars, which is the variable name equals array, like so. And let's put few cars in here. The first thing I'll do is Volvo always separated by a comma in between the individual elements here. And let's X2 and X1. Bmw. Yeah, very nice. Okay, next, double-quotes. Let's do Toyota. Okay. And put a semicolon on the end. Alright, and let's do echo. And let's do double-quotes here. Unless ride I like, and then add another double quote here and then dot. Let me tell you what the DOD is. A DOD is what is, what is known as concatenate or, or connect concatenation, which means that joins things together, elements together here. So we're gonna write cars. I'm hoping that your top along with me to kinda learn. Learning by doing is, is always the best way to learn. So, so I just typed it in there. So I was going to ask you, what do you think goes here for Volvo? Which as you may have noticed, 0 goes here because that's the first, the first element, the first car. Alright, so let's put a dot and then double-quotes. Again, let's put a comma and a space here. And let's put a dot, and let's put the next car. So as cars, square brackets, can you guess what the next number is going to be to reference BMW is going to be one awesome job if you answered that. Ok. And let's put a dot here and double-quotes space and, and let's make another space and then a period or concatenate or let's see here, cars. And the next one is going to be two for Toyota, okay? And dot double quote. Make it put a space here, double quote and then a dot in there, and catenate and semicolon. Alright, so let's save that. Open up your browser. And let's stop in array one dot PHP. And there it is. I like Volvo, BMW and tell you a, and that's what we did. First, we created the array that has individual cars are in here. And we're all, we also echoed those out and we referenced those atoms within the array here. So I hope you understand how the regular arrays work. And of course, if you have any questions, let me know. Next. We'll be moving on to the associative array. Okay, thank you and see you next lecture. 22. Associative Arrays: Okay, welcome back. Alright, in this lecture we're going to review associative arrays. Alright, so let's see. Alright, so we'll make a commutative associative array I. And let's do this. Let's, let's copy this. And let's add it here. And let's modify it and still rewriting the whole thing will just modify. Alright, so we wanna put the arrow here or the rocket. And we'll do a. Let's put blue here. Bmw put the equal and greater than symbol, the arrow. All right, and let's put red. And for Toyota, let's do something different here. Let's do this one. I'll put a number here. Alright, and remember with numbers as we'll review more later numbers, you don't have to have a double quote. It's not, it's not required for integer. Alright? So we have all of our different things in our array here. Alright, so let's do this. Let's first try echo. The hotel V0 is okay, and let's do concatenation here. And we have to do the variable name, which is here, cars. And we have to put single quotes in here. And we have to add whichever one of these, the Volvo, BMW or Toyota. So let's talk may involve oh, one thing I want to mention, you cannot. It has to match word as well as the case. So if this was, I'll show you what I mean. So if we save this and we open up our browser here, and I'm gonna add a break here. Let me add, let's do another concatenation. Double-quotes BAR, like so. Go back, saved it, go back and hit, refresh. All right. Come on. I know. Now added the right. Okay. Sorry. I have to add the brake up here as well. Okay. Let's go back to here. Okay. And see the Volvo is, unless put on concatenation here, space, like so. And let's go back and I saved it and reload it. And it says the volume. I'm sorry, I don't like the lowercase t there bothered me. Alright. Reload. And it says, Navaho is blue. So here's why. Here's what we've done here is we have cars, Volvo, and when you call this element, it's going to use the value. This is the key. This is about you. The now we're using the Volvo as the key to get the value. Okay, so the next thing we're gonna do is let's copy this. And I want to show you that will also work with the integer here as well. So let's say, let's say the Toyota gets say, and let's put Toyota here. Remember a capital T needs to match the case. If I can spell it right here. And let's put, instead of this, must put double-quotes, mpg miles per gallon, OK, save. And taking out. The Toyota gets 32 miles per gallon. So we've used things in our array, we use, in this case, we use Toyota, which is the key and the value is 32. And this is how we, we actually grabbed 32 as the value. So okay, so he understood that. And if not, contact me and as always, the next one we're going to review is the scary one, the multidimensional array. Okay, we'll see you there. Thanks. 23. MultiDimensional arrays: Okay, let's cover this scary multidimensional array. Just remember, all the multidimensional array is one or more arrays with VN and array, that's all it is. So when we cover this, you'll see that's not that bad. Alright, so the first thing we wanna do is we want to create a variable and lets them at cars equals. And then we have to type the keyword array. And let's hit Enter. And let's see. And let's do an open parentheses. And it's also going to create a closing for this c. And let's write the word array to ours, K. And let's do this as top-down bhava and comma. Let's do 22 and say 18. And I don't want to space their date T. Okay. And you always have to put a comma underneath the line that you're working on are on the end of the line. And let's copy this. And let's copy it. Let's do forays. So that's 1234. Okay, let's change this to, let's say BMW. And let's change this to sob. And was changed this to maybe Ford. Okay. And let's change these numbers here. Let's change. I hope you're topping along with me because like I said before, it's the best way to learn is by doing OK, 15. And let's see 13. And let's change this sob 252. And the Ford, It's going to be any numbers you like. I'm just putting in these specific numbers, but if you want to put whatever other numbers, that's fine too. Alright. So I think when I made my comments, I think you understand it better. Remember we were up here rotting the regular array. Remember each one of these was a number 012. So when we, when we put the call to the array here of 0, we're referring to the Volvo, BMW to Toyota. Same thing applies here. So essentially this is going to be rows, the row, and let's think of this as a row. And this one is going to be row one. This one is going to be row two. We put a space there, and this one's going to be row three. Alright? And let's go underneath it. And let's do, I'm just writing a comment, 0 comma one, comma two. And I'll kind of do this. Alright? So this, this row here, or I'm sorry, column here is 0, this column is one, and this column is two. So in that case, if I'm referring to above o It would be 00 because it'd be this column and this row. If I want to refer to the number two and solve, it would be 22. You see that? Alright, so let's add, let's make a little more clear. Alright, so let's go here. Let's put a semicolon here at the end. And let's do echo cars and square bracket 0. And my CEO to sue the 0. And let's do it. Come back to here. And let's do a concatenation here and double-quotes. And let's do a colon. Remove that one. Let's type in stock colon. Let's do it. Another double quote, concatenation here. And then let's type be an cars here, 0. Let's do the next 11. And dot and double-quotes comma. And let's write the word sold. The C semicolon. Alright? Double quote, period, concatenation, dollar sign cars 0 to k and dot double quote, dot BR. Alright, so let me explain what's, what's going on here. That we put a double quote here. Alright, let me explain what's going on. So we're at kind of echoing out cars 0, miss this. Make sure each one of those right. Yep. So cars 00. So like I was saying earlier, If we're referring to the array 00, this row is 0 and this, I'm sorry. Yeah, that's right. This row is the row and this column is 0. So that's going to echo out Volvo. And this is how manys and stock and this is how many volcanoes have been sold. So in that case, so how many did we haven't stopped? We have 22. So this is row 0 and this is column one. Hope you see that. So, but let's, let's save here, and let's go back to here. And here. We've got Volvo install a 22 and sold 18. Do you see that? All right. Let's do it again. Alright, let's copy that. Let's go here. And let's do this time. Let's do 10. And the cars is going to be 11. Knotting n. And let's do 12. Will happen. 12, okay? All right. Now, what do you think's going to happen? It's going to echo out one. This is row one, BMW. And then it's going to do column 0. So, So we've got row one, column 0. Alright, so that's going to echo out BMW. This one is going to do as 11. It's column one. And if BMW is 015 will be one, Okay? The next one is going to be cars 12. So this row is one and this is 012. Do you see that? So again, this is row one. And we're looking for to 012. So let's see what it does. Bmw and start 15131513. So we'll continue. I'll go a little faster on the last two here. I c. All right, so this one is going to be too, this one's going to be three. This one is going to be 2323. And I think it's two bronchi and then two and then three at the bottom. Alright, Let's check it out. Exactly. So on this one, it's row two, which we know is going to be this row here. And it's going to be the very first one which is 0, that's sob. And then the next one is going to be row two, N1, which is going to be five, and this was going to be 22, which is two. So now you go and honest look at it again. And that's all there is to it. You are just referencing the array like this. So if you have any questions, let me know. Thank you and see you in the next lecture. 24. Review Data types: Hello and welcome back. In this lecture we're going to talk about something called datatypes. So what, what are data types and data types are? Simply define the type of data a variable can store. And we'll cover four of the primitive, or also known as scholar types plus something called a null type. So the first thing I want you to do is just right-click in your eye the editor. And then she typed data, underscore types, dot PHP, like so. And then open up your PHP and PHP tag and then close your PHP. And the first one we'll cover some called Boolean. And it simply means true or false. Okay? And it could also be a one or 0. Great example is, let's declare a variable called flag. And we'll give it a boolean value of false. Okay? And we'll also do a conditional statement called an if statement to test it. And remember from our previous lectures that we'll do if open parentheses, close parentheses, open curly brackets, closed curly brackets, and we'll do it go. Yes. And then let's do a break and here. Ok. And then do else. Echo. No. Two and c and d are capital Y. Makes sure that's good. Okay, we've got our semi-colons on the end. Ok, so I have to do is put dollar sign flag for a variable equals equals, which is a comparison operator, which we will cover in the next lecture. And we'll do faults. Wacky, misspelling it, but okay. Alright, so we'll save it and we'll open up the browser and we'll type the datatypes here, which I already have it in here, but you can enter and we'll click yes, because the boolean value is assigned to the flag variable is faults. And so we're checking here to see if it's false. Now, if we put this to true, like this, and we reload, it's going to equate to know which it's not equal to false. Alright, so let's move on to the next one. The next one is going to be called integer. All integer is, is basically a number. So remember the big thing you have to remember with integers is you can't wrap a single quote or double quote around it just like the Boolean. So I can do. Whatever number I'm not like so in it with a semicolon and and we'll cover one that's very similar to that. And it's called a, it's called a float. And a float simply means the number has a decimal point located in it. So we'll do num two equals C2, three for, for whatever, dot, whatever. Okay? And that is a float. And remember no single quotes or double quotes. So the next one that we want to cover is called strings. Okay? And, and strings do have to have a double quote or single quote. Okay? And I'll, I'll show you the difference between those, the single and double. What does that mean exactly? So let's do this is to echo. And we'll do, let's do string C dollar sign as two or one equals double quotes. Double quotes. This is my Hello World. Okay? And let's save this and reload. And we get no from this Boolean If statement here. But this is, this is my Hello World. Now watch this. We can also, you can also add in a variable. So let's do num for example. So now it's going to say this is, this is my Hello World, and then it's going to echo out this number. Okay? So let's go here. And as you see it did you can also do the same thing with a float. And you'll see that it actually echoed out that number. Okay, so let me show you the difference. 20th single quote and a double quote. So if we go this t R2 for example, and we put this, well, I'm sorry to do single quote, unquote. This is why I say, this also works. And do here. And we also, I'm going to do a break here. And we'll save it. And you'll see it also adds this. Now, here's the thing you've got to look at. If you try to put a variable within single quotes like this, what it's gonna do is it's going to treat it as just text. So if I hit refresh here, you'll notice it's not actually running the echo and out, echoing out the variable. It simply printing the variable. That's the big difference between the two. So what you'd have to do in this case is something called concatenation. So if I go here and put a single quote, then I have to put. A period which is concatenation. I think we've seen this in previous lectures, what we're going to review that more. And then another one here. And then if you do it like this and you hit refresh or I'm 24, what did I do wrong here? Okay. So here, let's do, let's do a break here and do another single quote here. Okay, since we added the brake and the other single quote on the end will go here. And as you see when you load it, you see it shows the variable here. But you just gotta remember that if you don't add concatenation in here, it's going to treat it like I say it as just a regular text string as you've see. Alright, so I hope that's clear. All right, the next one we're going to cover, which we've covered in previous lectures is called the array. That's also a datatype. And like we said before, array is just a collection of, of other things within one variable name. So if we do names equals an array, and let's say we've got Joe, Jack. And let's say Tom just reviewing this from previous lectures. Okay? And we come here and we do echo, echo a names. And remember from previous lectures, if we want to refer to, let's say Jack, then we would put the single quotes in here. And when you put one in here, I'm sorry, not single quotes would just put one. And, and then we'll do, end it with a semicolon. And let's save. And now we should see Jack show, show up here. And which we do. So in a really need to put a break here. Okay? And thus save. And let's do manage UC Jack, we wanna reference Tom, remember, first one starts with 0, then one, and then two. So let's do Tom, which is 012, like so. And let's go here. And as you see it shows Tom, Okay, so that's arrays. So let's move on to the last one which is called. So let's put a, let's do this. If I can type it here. Okay, let's make a declared a variable called a N-U-L-L. And let's do equal to just to double-quotes, which means there is no value. That's what no means is there? There it's a place holder, but there's no value assigned to it. And you can do it with something. You can use it similar to the way we did Boolean. And what I mean by that is if we do, let's do this. Let me copy this here. And let's put that here. And let's put a null here. Okay? And instead of putting the true or false, we'll just put the actual two double quotes in here. Alright? So it's going to be, if it's equal to nothing, which it's just the absence of value. It's still love that is still available, but it's the absence of, of any value. So let's do save here and reload. And yes, because it is equal to nothing. So that's pretty common in development. To du is equal to true or false or it has no value. And that's kinda what I'm, what I'm trying to show you here. So I hope, I hope you understood the datatypes here. The next thing we'll be covering is called operators, and we'll see you in the next lecture. 25. Intro to Operators: Alright, let's review the logical operators. So if we on the left panel, if we right-click and choose New File, and we just name it log dot PHP. And as always, let's open up our PHP tag. And let's put some spaces and then close our PHP tags. And then the first thing we wanna do is let's declare a couple of variables. X equals $100 sign y is equal to, let's say 50. Okay? And to kind of explain how this works though, the easiest way is to do an if statement. So let's do if open parentheses, close parentheses, open square bracket, close curly bracket, open curly bracket, closed curly bracket. And then now let's, The first thing we will review is the, And so let's do EF dollar sign X is equal to, remember the 2x equals is a comparison operator equal to 100 and a ND. Y dollars on y is equal to 50. We'll echoed. Yes, it is. Okay, but let's make sure we put a semicolon. Else. Curly brackets, curly braces, echo. No, it's not. And there. Alright, so what's going on here? So we're declared x variable and it's equal to 100. And we declared y variable equal to 50. So if x equals to 100, which it does, and y equals to 50, which it does both of these, to do so they both equate to true. It's going to say yes it is. So if we save it, Control S or file save, and we top in, let's see. Log. Yes it is, because 50 x is equal to 150. So what it, what if we do 51 k? It should say, no, no, it's not. Ok. So it's working as expected. So the other thing we can do with a hand, which I typically do is I use the pipe symbols, which is on your keyboard, it's above your Anarchy. If you hit shift and the key to the top right of your Enter key is called a pipe symbol. And we'll put two of those, looks like that. And we'll save and do the same thing as just say No, it's wrong to say, I'm sorry. This is for the, or the and is the ampersand ampersand save here? And no, it's not because instead of riding AND you can put the double. I get it right here. Double ampersand symbols, it does the same thing. That means ant. Alright, so let's do, or we can do or like so. We'll change this back to 50. So the way or works is if x is equal to 100 or y equals to 50, it will equate to true. And what I mean by that. So let's go save and we'll hit refresh. Yes, it is. So x is equal to 100 or y equals to 50. So if we change this 50 to 51, for example, it's still going to equate to silicon. Equate to Yes, it is. Because one not one or the other is going to is going to be true. So if we hit save here and refresh, Yes, it is, even though 50 was equal to 51, x is still equal to 100. Okay, so if we change this one to 101, which both of them are, neither one of them are going to be true. It's going to say no, it's not. So if we hit to save control AS or file save and refresh, it's going to say no, it's not, which it does. Okay. So the symbol for that is that's what I was trying to do earlier, is the two pipe symbols looks like this, works the same way. I control, hit control AS I wanna hit refresh. Here, know what's not. If I put this as a 100, it's gone to, the statement's going to equate to true. And so yes it is. All right. So that covers, that covers or the next one is simply the not. So if we do this, this, take this out. And let's do if dollar sign X is not equal, the two equals symbols, let's say 90. And curly brace here. Echo. Just helloworld, I guess. Okay. So what's it? What this is gonna do is it's saying if x is not equal to 90, then equate to true. If it's not equal to 90, the statement's going to be true. So it should now Echo helloworld, which it does. Now if I said, if x is not equal to 100, let's do an else here so you can see else, echo and save. Alright. So x is not equal to 100. Echo this. And so what we should see is node, which we see, nope. So basically this, if it equates to true, is going to show this. So x is not equal to 100, it is equal to 100. So it's going to show that else echoed. All right, so, so that's what we reviewed in this lecture. We reviewed, and we reviewed or, and we use the word and an OR. And we also use the symbol four and which is the double ampersand, as well as the 4x, which is a double pipe and we reviewed not as always. If you have any questions, be sure to let me know and I'll be glad to help you. Next, we're going to review something called string operators, will see you in the next lecture. Thank you. 26. Arithmetic Operator: Okay, let's get started. Okay, in this lecture we're going to review something called arithmetic operators or math operators. So the first thing we wanna do is make sure that you have your IDE visual codes. Do you make sure you have it open and ready? If not, pause the video and open it up. And then also make sure that you have your example running. As you see, mine is running. If not, you, you open it up, should be under your your start and under Programs are something you should be able to find it in there and make sure you choose Start on both, which we reviewed in previous lectures. So what I want you to do on the left-hand side as right-click and choose New File. And let's name this math underscore operator dot PHP. Okay? And then lists, of course, open up our PHP tags and we'll close the PHP tag here. The first 1, first thing we wanna do is we want to actually declare variables, a couple variables. So let's do dollar sign. One equals, let's say tin. And remember when you have a number, you don't have to put single or double quotes around it. Make sure you end it with a semicolon and then do a dollar sign nom two equals, let's say six. Okay? And then we're going to echo out. Let's do echo dollar sign num one. And then let's put up plus symbol, i'm sorry, plus. And thus do dollar sign num two. And let's save and beyond that, we have our exam running now and we should be able to open up our browser and go to local host. Whatever you name, names your project folder. Mine is called Ma project and here, top in math, MA th underscore operator dot PHP. Okay, so hit Enter. So our total is going to be 16, which is correct. Ten plus six is 16. So we'll also do, let's do the subtraction. So let's do just a minus here. Well, let's save it. Or you can do File Save. I just do control S to save. Just a habit. So let's refresh and the values is four, which is correct. All right, so the next, next one we're going to review is the multiplication. So if we do a star which is above your number eight on your keyboard, shift eight. And let's see. And then let's save it here, and let's refresh. And 60 is the correct answer if you multiply 1010 times six, alright, so the next one is division. So if we just do a forward slash, it's up under your question mark on your keyboard. And I'm doing patrol S, or you can do File Save and hit Refresh. That's gonna give us the correct answer here. Alright, so the next one we're gonna review is something called modulus. And this can be a little bit confusing, but I will try to explain it. So the modulus is basically a percent sign like so. So if we do Save and we hit refresh, what do you think the answer's going to be? Did you think it was going to be four? Okay, so what the modulus does, How many times will six go into tan? One top right is going to be that goes into 101 time and you're going to have four left over. And that's where the modulus comes in. It's four. So it's basically what, whatever the remainder is. I once going to cover the exponent, but I think, I think that's a little outside the scope of the beginning PHP class. So I'll wanna include that one, but you can read up on that if you do PHP operators. And then top in exponents, you can read more on that. But anyway, if you have any questions on this, please let me know. Alright, so we'll move on to the assignment operators. Thank you. See you there. 27. Assignment Operator: Hello there and welcome back. In this lecture we're going to review what is known as the assignment operator. You've kind of already seen the assignment operator in our last lecture in regards to the math operator. We actually did an assignment here. All in assignment operator is, is basically at assigns the value on the right side to the variable. Now, remember, when we assign the value to this variable, it can be an integer, which is what you see here now. Or it could be a strain which could be either with double-quotes or with single quotes. You can use either one at like so both is valid. So we will quickly move on to something else here. Let's see. Let's say for example, that I want to actually do some, you know, some top a math functionality here or function here. Let's, let's try this. So what if, what if we want to define or declare a variable equals, let's give it a value of 20. And let's say that we're going to use this. We can do dollar sign X, which is we know as 20 in this case, is plus or equal to 100. And then will echo out dollar sign x. So what do you think's going to happen here? Okay, So if you said it's going to add up to 120, you'd be right, because we're assigning the integer 22, this x variable. And it already knows that it has the value of 20, but we're adding 100 to it, so that would come up to 100. So if we go File, Save here, go back to the browser. And it comes out to one. To me. Do we can do the same thing with subtraction, multiplication, that kind of stuff. So say for example, we had 50 here and we did a minus here instead of the plus symbol. And let's do 30. So what do you think's going to happen here? We, well, we should get 20. We do we at 20. So we'll do one more. Here. It's not that difficult to understand. Let's do multiplication. So if we have, let's say this is ten here and this one is six. And let's change that to a star or an asterisk here, which means multiplication, which we reviewed in last lecture. So we should get 60 here. So let's refresh and we do, we get 60. So that goes to show you, we can go ahead and assign numeric value or an integer to a variable. And then we can do the math while we're assigning here. As we do tn that the dollar sign x equals Tn. And this now has a value of ten. But we can also, in addition to that value, is we can do some type of arithmetic function on that as well. Or arithmetic functions such as multiply it times six, which in this case gave us 60. So I hope you understood the comparison operator. I'm sorry, the assignment operator. If you have any questions, please let me know. Next, we will go to a review the comparison operator. Thank you very much. See you there. 28. Comparision Operator: Hi, in this lecture we're going to review the comparison operators. The thing I'd like to mention about the comparison operators, this, this is something that you're going to be using a lot in PHP programming. It's not a very hard concept to understand. It's just a few rules that we're going to review. So the first thing I'd like you to do if you have your IDE open or your visual Code Studio, if you have it open to style on the left-hand side, let's right-click and choose new file and type in compare dot PHP here. And let's open up our PHP tag. And let's close our PHP tag. And the first thing we wanna do is review something called the equal comparison operator. So we're gonna go in here and let's do dollar sign x equals, let's say 100. And we don't do dollar sign, why? Equals? And we'll make it a strain of 100. So the value is going to be the same. Ones is integer and ones that string. But your PHP is going to see it as one of the same. So if I go here and I type in if, let's do an if statement that we've reviewed in previous lectures. And dollar sign X, o pure top and along with me. So you can kind of get more practice because it, practice definitely makes perfect in programming. So we're gonna do two equals, which is the equal, a comparison operator. So we do dollar sign equal, equal. And then we'll do dollar sign. Why? And then we'll do echo. Yes. It does. Like a spill and less close it with semicolon and let's do else. We'll just do it. I'll be here. And we'll put it does not. Okay? So we can kind of see from our if statement if R equal is working right? So this is just a common example of how you would do it in your own, you know, program. So if we save it here, we go back to the browser and we type being in compare dot PHP. And we hit Enter on the keyboard. It's yes it is because the x is equal to 100. Integer in the y is equal to 100, the string. So they are, so, which leads me to the next. A comparison operator which is going to be called the identical. So what does the identical mean? First of all, the identical is, is represented by three equal sides. What it means is the tight has to match for both. In this case, the 100 integer is different from the 100 string. So what, what do I mean by that? So if I do double equals here, I'm just comparison. I'm just just checking to see if it's a equal to a 100. But if I add three, if I add three equals sin equal signs in here, and I hit save. Now it's not equal because 100s integer is not the same as 100 strain. If, if you've, if you're checking for the type. So if I go here, hit refresh, as you see, it says no, it does not. So so that explains that. So another one that you commonly use is called the not equal. So if I come in here and let's say, let's say add to this, this, if I go, if x is not equal to y. Ok, so let's change this to something else was say for me. Okay. So if x is not equal to y, then that was put the else. Yes. Yes, it is equal to remove this extra double-quotes. And okay, so I'm actually checking, and if it's not checking x, which we know the value is a 100. If it's not equal to y, which is 20, it's going to echo not equal here. So let's see, which it does say because y, x is not equal to y. So we're going to echo this else. So if we changed both of these to say 100, then and we refresh, it's going to be equal. Yes, it's equal. So that's the not equal. The other, there's other ways to represent this. We could go to, we could do, which I never do this. That also represents the same thing. So. So that's, that would be correct if this is, say one Tn. We go back to the browser and no, it's not equal. So it's the same thing, but generally, most developers, including myself, just do this. Okay, so back to our initial issue where we checked if the string was equal to the 100th integer. That's fine. It doesn't care here, like so if you do, it's going to give us the same thing, really. Yes. So it is equal because both of these are the same. But what happens if we do are not equal? So what happens if we do this? We save. And it should say not equal, which it does because they're, the type is not the same, just like we saw before. Alright, so let's do, let's go over the next one. It, which is called the greater than. Greater than, is always represented by the the right arrow. So if x is greater than y, it is greater. No, it's not greater. Okay? So we'll just change these to integers to make, make it easy. Alright? So if x, which is a 100, is greater than 20, why? It should echo in? It is greater. Solicit save here, and let's refresh. It is greater. Alright, so, and the next one will review is the less than, which is the opposite. So if x is less than y, in our case it's not. So click save, and we should get no, it's not greater. And it does. That's correct. You can also do a greater than or equal to. So if x is greater than or equal to y, echo is greater. In our case, it is. So we hit save. I'm sorry. If, if I didn't say it, what I'm doing is hitting Control S alma keyboard is add up a habit. You can do File Save to test these things yourself. I apologize if I didn't tell you that or you were confused as to why kept changing. That's what I was doing. So we'll hit refresh it. It is greater or it's greater or equal. You can do the same thing with less. So in our case it's going to say no, it's not greater because X is less than or equal to y in our case it's not. So I did control S to save. And no, it's not greater. And that's the comparison operators. It's really not that difficult. I hope you have a firm grasp on it. Maybe, maybe review the video a few Tom's. Plus there's lots of great, great resources out there on PHP.net as always, is a perfect resource for, for comparison operators. Alright, next thing, the next lecture we're going to go over. Next thing is going to be increment and decrement operators. I'll see you there. Thank you. 29. Increment and Decrement Operators: Hello there and welcome back. In this lecture we're going to review increment and decrement operators. So basically all it means is you're adding one or subtracting one. But as you see on the screen here now, you weave. In previous lectures, we've reviewed the increment, at least the increment operator here. As it loops through the loop, the increments going to increment the number by one. So let's do this. If you have your, if you don't have your editor or IDE open, go ahead and open that. Now pause the video and open it. If not, you do. Good. We'll go ahead and let's right-click on the screen on the left panel and choose New File and lets us create a file called IMC for increment dot PHP. Alright, and then let's open up our PHP tags and less close PHP. And let's declare a variable dollar sign x equals ten. And then we'll do actually echo. And then we'll do, we'll start with the pre-increment here. Now let's do the post-increment first. That's probably better. Dollar sign X and then plus phis and less do concatenate double-quotes less than VR. And if you're talking with me, that's great. Because the more you practice, of course, the better you'll be. You'll be at PHP development. But it's always a good thing. So let's do echo. And then dollar sign X a plus for us, okay? Semicolon. So what's going to happen here is it's basically going to echo the variable. What you're gonna see on the screen is TN. And then it's gonna say, okay, Tn. And then that number 11 is, the number 11 is actually going to apply to the second one, so you don't see 1011. So as we go here, the met, Sure, I'll say that a Control S on my keyboard. You can do File Save. So when we open up, our browser will top in I-N-C dot PHP, and you'll see 1011. Let me explain this again. So our initial variable that we declared has a value of tn. So when you go to Echo is kinda show tn because it is considered post. You're incrementing after the variable has been defined. So it's taking this increment and moving it to this one. So that's going to show 11. To emphasize this point, will go here, dollar sign C, dollar sign X, and just do this. And now we should see 101112, which we do, needed a break there, but you can kind of see what's going on. All right, so that pretty much covers the post increment. Let's do the pre-increment. So if we take the plus signs out here, okay, and let's put it before the declared variable. And let's hit save. Now, what do you think's going to happen? Ok. What's going to happen is it's going to show TN or I'm sorry, 1112. It does. So see what's happening here. Before it echoes out the variable x. It's essentially, I'm incrementing it first and then it's echoing and out. And and the same with the second one. So that's how we get 1112. Alright, so let's work with the decrement. Which decrement is pretty much just subtracting. That's all we're adding an increment and we're subtracting and decrement. So same thing applies here if we do two minus symbols, like so, and we hit save. So what's going to happen is it's going to show 109. Because remember, tan is our initial value. It's eco analysis. Okay? I'll make the variable, Oh, it's tn. Okay? So this really is not doing anything but decrementing it for the next variable. So it's almost like this doesn't even have to be here. This carrying this decrement over to the next line. So same thing here. And you'll see the same thing. So what if we put it in the front of the variable like this? So if we do that and we save, and we hit refresh, what do you think's going to happen? It should go 98. It does. So I hope you understood the increment and decrement operators. That's pretty much all there is to it. It's not that difficult if you understand essentially what it's doing to start with which dependent upon if it's posed to pre, whether it's going to echo out the variable first, or it's going to increment or decrement the variable first. So as always, if you have any questions on this, please by all means, let me know and I'd be glad to help you understand a little bit better. So moving on in the next lecture when we move it onto logical operators. Ok, we'll see you there. Thank you. 30. Logical Operators: Alright, let's review the logical operators. So if we on the left panel, if we right-click and choose New File, and we just name it log dot PHP. And as always, let's open up our PHP tag. And let's put some spaces and then close our PHP tags. And then the first thing we wanna do is let's declare a couple of variables. X equals $100 sign y is equal to, let's say 50. Okay? And to kind of explain how this works though, the easiest way is to do an if statement. So let's do if open parentheses, close parentheses, open square bracket, close curly bracket, open curly bracket, closed curly bracket. And then now let's, The first thing we will review is the, And so let's do EF dollar sign X is equal to, remember the 2x equals is a comparison operator equal to 100 and a ND. Y dollars on y is equal to 50. We'll echoed. Yes, it is. Okay, but let's make sure we put a semicolon. Else. Curly brackets, curly braces, echo. No, it's not. And there. Alright, so what's going on here? So we're declared x variable and it's equal to 100. And we declared y variable equal to 50. So if x equals to 100, which it does, and y equals to 50, which it does both of these, to do so they both equate to true. It's going to say yes it is. So if we save it, Control S or file save, and we top in, let's see. Log. Yes it is, because 50 x is equal to 150. So what it, what if we do 51 k? It should say, no, no, it's not. Ok. So it's working as expected. So the other thing we can do with a hand, which I typically do is I use the pipe symbols, which is on your keyboard, it's above your Anarchy. If you hit shift and the key to the top right of your Enter key is called a pipe symbol. And we'll put two of those, looks like that. And we'll save and do the same thing as just say No, it's wrong to say, I'm sorry. This is for the, or the and is the ampersand ampersand save here? And no, it's not because instead of riding AND you can put the double. I get it right here. Double ampersand symbols, it does the same thing. That means ant. Alright, so let's do, or we can do or like so. We'll change this back to 50. So the way or works is if x is equal to 100 or y equals to 50, it will equate to true. And what I mean by that. So let's go save and we'll hit refresh. Yes, it is. So x is equal to 100 or y equals to 50. So if we change this 50 to 51, for example, it's still going to equate to silicon. Equate to Yes, it is. Because one not one or the other is going to is going to be true. So if we hit save here and refresh, Yes, it is, even though 50 was equal to 51, x is still equal to 100. Okay, so if we change this one to 101, which both of them are, neither one of them are going to be true. It's going to say no, it's not. So if we hit to save control AS or file save and refresh, it's going to say no, it's not, which it does. Okay. So the symbol for that is that's what I was trying to do earlier, is the two pipe symbols looks like this, works the same way. I control, hit control AS I wanna hit refresh. Here, know what's not. If I put this as a 100, it's gone to, the statement's going to equate to true. And so yes it is. All right. So that covers, that covers or the next one is simply the not. So if we do this, this, take this out. And let's do if dollar sign X is not equal, the two equals symbols, let's say 90. And curly brace here. Echo. Just helloworld, I guess. Okay. So what's it? What this is gonna do is it's saying if x is not equal to 90, then equate to true. If it's not equal to 90, the statement's going to be true. So it should now Echo helloworld, which it does. Now if I said, if x is not equal to 100, let's do an else here so you can see else, echo and save. Alright. So x is not equal to 100. Echo this. And so what we should see is node, which we see, nope. So basically this, if it equates to true, is going to show this. So x is not equal to 100, it is equal to 100. So it's going to show that else echoed. All right, so, so that's what we reviewed in this lecture. We reviewed, and we reviewed or, and we use the word and an OR. And we also use the symbol four and which is the double ampersand, as well as the 4x, which is a double pipe and we reviewed not as always. If you have any questions, be sure to let me know and I'll be glad to help you. Next, we're going to review something called string operators, will see you in the next lecture. Thank you. 31. String Operators: Okay, let's review the string operators. Ok, so what is the string operator, or basically is system concatenation. So I'll show you two different ways to concatenate variables together. So the first thing I want you to do on the left-hand panel here, right-click and choose New File. And let's name it strain dot PHP. Okay? And let's open up our PHP tags. And in here, a list to dollar sign text1 equals hello. And end it with a semicolon. And let's do text T2 equals world. Okay? And semicolon. And if we want to echo these out as a matter of fact, here's a little trick. If you ever want a space in between you two variables, you can add your space here. So that's what most developers do, is just add the space here. So when we come in here to do the string operator, use the string operator, we can do echo, dollar sign texts, one dot or concatenate the dollar sign text to. Okay? And so we open up our browser and we get string dot PHP. And it says hello world. You notice the spaces in there and all for text1 and text2. Okay? So what if we wanted just to have one variable as supposed to two, and maybe we will add an, another variable here at the top. So what we can do is let's say we add a third variable here. List, name it, text three equals. Let's do another space. See, citizens see at t as e, n and a semi-colon. Alright, so we'll do dollar sign text1 and then put our concatenate equals text to like so. And we'll also do dollar sign text. One. What concatenate it or add onto it text here. And then now, look at semi-colon. So now all we have to do is is how text one here. You see that? So if we do text1 and hit refresh, look, it says hello world citizen with one variable. So essentially what we did is we've declared texts 123 and we took the text1 and we concatenate it. It are actually concatenated on Tx2, and we also concatenated on text three to text1. So then what happens is, is it goes out, says OK, text 123 are all part of text1 variable. And that's what you see here. So that's all there is to it for the string operators. And I think that will now conclude the string operators. Next, we will be reviewing something called functions. 32. Intro to Functions: Hello and welcome back. I'd like to take a moment to thank you for, you know, number one, taken my course at number two, making it this far. I'm, I'm hoping that you're gaining a lot of knowledge so far from my course. As always, if you have any questions, let me know. So now we're going to embark on something called functions. So what's a function? A function is a self-contained block of code that can be used over and over again whenever, whenever needed. What makes a function useful? A function is useful because you don't have to rewrite code many times over and over again. Write once and you can use it throughout your application. It basically saves time. And this is a self-contained block of code that you can pass parameters to, and it will echo out things that you want within your application. So what tops the functions, what tops functions are there? There's user-defined functions and built-in functions. So let's review user-defined functions in the next lecture. 33. Functions (Part 1): Okay, let's review user-defined functions. Alright, so the first thing we wanna do is make sure obviously that you have your IDE open here, your visual code studio or whatever editor that you prefer. On the left-hand side, let's right-click here and choose New File. And let's name it functions. Dot PHP. Ok, and as always, let's open up our PHP tags and less close it down here. Alright, so we're going to write a function based on lists, do groceries, everybody buys groceries Unless, let's create a scenario where you buy groceries 33 times a week. And you want a function to figure out, you know, your total cost based on taxes, based on, you know, including the food list and things like that. So the first thing I'll do, let's make a few comments. Let's do Mondays. Cost. And let's say Monday we bob breakfast food. Breakfast foods. Okay. And let's say Wednesday. As we buy, let's say Dinner foods. Ds, let me capitalize this because it will drive me crazy if I don't. Okay. Alright, and then let's choose one more day that we we buy groceries. Let's say Saturday. Saturdays. Yeah, Saturdays. Calls. And let's say we buy a snack foods on saturday AS flex fail. Okay? And let's do Wednesdays. Alright, so the first thing we will do at the top is less Create. Let's start our function. So anytime that you write a function, it always starts out with the keyword function, like that. And you open parenthesis and close parenthesis. And just like with the loops and all that, and if statements, open parentheses, open curly brace, and closed curly brace, you, you see a pattern happening here. Okay? So the first thing we wanna do is we have function, but we have to give it a key word, the function name. So let's do buy groceries. I'm doing this in camel case, which is the, you know, didn't start I did not start out with a capital letter. But the next word has a capital letter, say CRO CER IES, buy groceries. Alright, is our function name. Alright, so the first thing we wanna do is. Let's figure out what parameters we want to pass. So let's pass the day. Less paths. The food. That's going to be your list of atoms that you purchase on that day. Less pass the, pass the tax. Okay? And let's go down here and let's go ahead and work on those these things. So let's do Monday. Costs for groceries equals let's say $100. Okay. And let's say for wednesdays calls, we spent Let's see, Mondays costs was a $200. Okay. And let's say Saturdays costs because we didn't want to spend too much on snack foods. So was let's say $20. That's always been on Saturday. Okay. All right. So let's do let's do the tax underscore UNASUR total. I hope you are tapping along with me too, because that will definitely help you learn the more you, more you top along and practice. Practice definitely makes perfect when it comes to PHP programming. So total tax equals, let's do call times and let's do tax here. Okay? So what we've done here is we've established some parameters here that we're going to be passed in through the function is going to be the day, the food, the cost, and tax. Now the way that, the way to think of, of the actual parameters and this is what confused me when I first started, is I thought everything had to be every every one of these different days of the week for grocery shopping, for example, had to be called the variable day. But don't look at it that way. You look at it like these are place holders. This is the first place holder, second, third, fourth, and I'll show you what that means in just a second. All right, so let's go down here and let's establish a variable called day one, which of course is going to be Monday. Okay? And let's do the same for Wednesday. Lists. List, name it. They two equals. And let's do that. The D in any S DAY Wednesday and day three. Day three is equal to Saturday. Okay. So what we've done is we've started our function, buy groceries, and we have some parameters here that we're going to be passing from these individual days, shop in days. So we're doing the cost, redoing the day so far. And let's cut it off right here. And let's go to the next lecture, which will continue on building our grocery shopping list with the function and the next lecture. See you there. 34. Functions (Part 2): Okay, and we're back. Alright, so let's go ahead and establish some more variables. Here. Declare some variables. So let's do, let's do Monday food list. Okay? Equals, let's do this, make this sort of like an array. And let's do milk. Comma bread, comma fruit, comma eggs, cereal, CR. Ok. And because this is after all breakfast food, I so let's do some dinner foods, so we don't do that WBD food list. And of course add the dollar sign because it's a variable. And let's do, let's do it's dinner foods. So let's do steak, potatoes, T TO ETS. And let's do a comma. Let's do some pasta. Let's do some rise. Let's do some Water. Is two soups. Okay. And let's do some snack foods for Saturday. So we're gonna call it Saturday food list here. And let's do, let's do candy, soda, chimps. Okay? And so we have the food list. So now lists, assign the tags. So lists, lists of, imagine our pretend that every day of the week, thank God, that's not. But every day of the week, it has a different tax amount is charged depending on the day. So let's do Monday, let's do M underscore tax equals and make sure you don't put is not a string, it's a float. So we'll do dot 07 here, and let's do the same for Wednesday here. Okay? Let's call it w tax, and we'll make it 3%, 7 percent on Monday, a little higher on Monday, and it drops down in the middle of the week because nobody likes to buy groceries in the middle but weak. So let's do for Saturday, let's name this Fs tax. And let's do 8% for Saturday. Okay? Alright, so now, the next thing we need to do. Is we need to actually call the function. And how you do that is you basically just call it the name here. And we'll do open parentheses, close parentheses, and we'll name it, are actually copy that. And we'll put it here. And we'll put it here. Okay. So this is what I was referring to in the last lecture. Whatever you put it in here, spot 1234 will be based off of this. It doesn't necessarily have to match this parable, like I say in the last lecture, that confuse me a lot. I didn't understand. I thought it had to match day had the match day food handle match food. The variables had to be the same then, but that's not the case. So I'll show you what I mean. So buy groceries, the first spot is called Day, so we're going to name the day. Day one. Okay? Let me remove this D here. Okay? And so this one here, the first spot for this function is called De To. Do you see that? Okay. The next one is called Day Three. Ok. I'm doing a File Save, or you can do File Save here. I'm just saving that every soft and it's by habit. The next spot is food. So what we can do is we can do a comma and we can add what less ADD MAN food list for Monday food list. Like so. Okay, so next we're going to add the Wednesday food list. So let's grab this variable here. And keep in mind, like I said, you know, the day one matches the day. The food lists matches the food. And keep in mind these can be, these can be anything you want that's going to be a, B, C, or D, really doesn't matter. It's it's all about the placement. That's all it's about. This is kinda like a, I guess, a field variables and assign the true variables here, which relates to the function. Okay? So let's do okay, so we got when studies food list. So next is going to be the cost. So Let's do this, let's do Monday cost here. Let's put a comma, because that comma matches up here. Let's do Wednesday cost. Here. I think I must have forgot this. The food lists for Wednesday. I'll put it in there. I think I put it below my mistake. Wednesday and Saturday. And C Let's do where it was a Monday cost, Wednesday cost. Ok. And see here, Wednesday calls and Saturday calls. This. Okay? And let's put the next one is the tags. So we'll do texts right quickly. And I see a comma here. Monday tax, Wednesday tax. Okay. And let's do Saturday tags here. Okay? So since we have all of these variables defined and the function defined here and each one will stop here and will continue in the next lecture. See you there. 35. Functions (Part 3): Okay, welcome back. Alright, let's finish up our function, our bag groceries function. Alright, so the first thing I added here with the text total. So we basically want to take our thee cost and multiply it times the tax to figure out what the total tax is going to be. So I'll show you that in a second. All right, so the next thing is we're going to do is call it b total. You can name it anything you want, but I just need to be total because I think when I first started thinking about this, I was gonna do budget instead of cost and I decided on costs. And so anyway, so let's go dollar sign, tax total. And then we're going to add it to the calls. Okay? Alright. And next we're going to do echo. And we're going to do my list to a space there, just concatenate lists put that day. Let's put concatenate here, like so. And let's do total grocery CRY below here. And is, and let's put a dollar sign here. It's not a variable, it's for the dollar amount. Dollar sign for that. Concatenate us do B total. And let's concatenate again and single quote. Let's do a break. And let's end it with a semicolon. Let's do another echo. And then we'll do my, what I'm gonna do a capital Y here. My tax amount is and let's put a tax like so. Let's put it at the end of it. Let's put a percent and I'll show you why in just a second. And let's do less than BR. So we have a break here. And let's do semicolon. Let's do one more echoed statement. Type in food, food list and hyphen. Let's do dollar sign food and HR for horizontal road, which is basically the line in between each one. All right, so what we've got here is we're bringing in all these different. Variables such as day one, day 23, Monday food Monday, Wednesday, Saturday. Food list. Monday. Monday cost, Wednesday costs. Saturday costs Monday tags, Wednesday tags and Saturday tags. So I think that's going to be everything. So I did a control S to save. Of course you can do File Save. And let's go back over here. Let's make sure we don't have any topos or any issues. If we do, we'll troubleshoot it. Let's go here and let's type in functions. Dot PHP. Makes sure you have your exam as always, started here. And let's hit this. Okay, so we got an error. Let's see what it is. Alright, so online 33, it doesn't like day three equals o. I see. Sometimes when it says that, if it says 33, it doesn't like it. Look, look at the lon, before it. See I miss the semicolon there. Alright, let's see if we got any more problems. Now. There it is. Okay. So here's what we got. Monday. My Monday total grocery bill was a $170. So we took the $100, we multiplied it to get the percentage of 0.7. so which is 7%. And then we went back and took that percentage and added it to the total which come up came up to a $107. And it also displays are fitted list for for Monday and a food lists for Wednesday and Saturday. And the same thing for Wednesday. We've spent $200 and the tax was 3%, and it came out to to $206. For Saturday, we spent 20 bucks on snacks and it's 8% tax and it came out to $21.60. Now here's the beauty of the function. Imagine having to, having to write this same block of code every time for Monday, Wednesday, and Saturday. I imagine if you had seven days a week and you had the add this code over and over again. What if you had, let's say another example would be if you had, say, three pages, page called monday dot PHP, Tuesday or Wednesday dot PHP or Saturday dot PHP. And you had, you had add that same code that's in this function on all three pages. You're, you replicate that over and over again when you get only need, when you only need to do it one time. And that's exactly what we've done here, is one time. Instead, you could still have those individual pages, Monday, Wednesday, and Saturday, but you can just do an include statement to include this function. And it'll work the same as it is as it does on the same page here. So that's user defined function. Next we're going to review the actual a C. So let me make sure I've got the right thing here. Next, we're going to review custom built in functions. Php has their own functions that are built in that you can utilize. So we will review that in the next lecture. See you there. 36. Common built in functions (Part 1): Next we're going to cover something called built-in functions. Php has a ton of built-in functions that you can use within your, your application, building your application. So to give you an example, let's go to Allah, post the, the link or the URL to this page here for you in the video. But as you can see, there are tons and tons of different functions that you can use. It just goes on and on. So what I wanna do in the next few lectures is just go over some of the common built-in functions. But you can, you can go through these and you can click on it and you can open on my check it out. It'll give you example code to show you exactly what the built-in functions do. Ok, having said that, let's go back to our editor here. Let me this. Alright, so what I'd like for you to do is right-click, make sure you have your Adi open. As always. It makes sure that you have your exam Control Panel or exam. Run it. Make sure that your Apache and MySQL's run it. Alright, so what I'd like for you to do is just right-click on the left side and choose New File. And let's type in builts, underscore functions, dot PHP, like so. Okay, so as always, we open up our PHP tags and we close the PHP tag. And so the save time, I'm just going to, because I've already typed these out. I'm just going to copy and paste on me. And if you'd like to, what you can do is you can actually pause the video as I go through a n-type this herself. Actually that would be very helpful. But I want to paste on the end because I'm going over quite a few. I think about 15 different common built-in functions. So this will save a little bit of time. But I'm going to explain line for line, kind of what's going on. Alright, so the first one we're gonna review is called HTML entities. And basically what it does is it's, it's really good function for say, for example, you create a form and you have a form field called name. And what happens is, is sometimes a malicious person will put things in that field to be submitted to the database or within your application that May cause problems with the application. So this is kind of like a security feature. Like I said, What it does is it converts you characters. And what I mean by that is let's see if I do control. S here or you can do File Save. And let's bring it up in the browser so you can kinda see what's going on. This is called built underscore functions dot PHP. Alright, so what's happening here? And this is with the HTML entities. You see how, let's say for example, the form has been submitted with a name. And if after it's been submitted, if we didn't have HTML entities, it would act the browser would the browser would show it as a bold word as opposed to just echo and out HTML, which means that HTML is essentially become an effective, ineffective at this point. So it didn't work whatever they were trying to pass through. So that's what the HTML entities does. So essentially what I did here is I created a declared a variable called STR. And this is the text. And here I echoed it with HTML entities as you see. Here, we add them without and, and this is the built-in function. Remember, a function basically has the name of the function, open parenthesis, close parenthesis, and whatever variable is, that's all there is to this, this function here. And then I added a break. And as you see here, I echoed out the variable SCR without being inside of a function. So this was kind of what is considered a unprotected variable. And this is protected here from when the form being submitted, like the example I gave earlier. Alright, so the next one is very similar to, to that. It's called HTML special characters. And these are very, very similar as to, as in, you know, what, how they work. The only difference is, is if they're symbols or something like that passed while showing you. Give it just a second here. All right, so maybe we've got, you know, single quotes or something like that. This is width special characters. See what I did here, um, and here it actually allowed the URL, the hyperlink, to be added to the text, as you see here. So this is basically with HTML special characters here. And also this is without special characters. So, so essentially, what I've done here is something a little different. Let me explain this a little better. So I declared the variable STR r1 and went ahead and added HTML spec special characters to it. And then I echoed out the string here. That's kind of what I said earlier. Protected, not protected. This is protected. So, and this is without special characters. So, uh, basically creating another string and the variable with the string as the H ref with the HREF tag. And so, so that's kind of the unprotected version. So you can kind of see how it reacts, showing just showing the hyperlink here and not actually allowing the browser to display it as operating. So that's those two. The next one is one that I've used a lot of times and it's another security ty, function built in function and is called strip tags. So, so this basically strips out HTML tags. This is, this is really good and, and what it's used for primarily is very similar to the other ones. The other ones convert it. This is actually strips and out. So let's say for example, you have a, a form and in the format has comments area. Well, you don't necessarily want people to be able to add HTML tags in there. So what this does is it strips it out. So let's do save here, and let's refresh Jansky per second. Alright, so here, here's what's going on. So echo with strip tags functions, which is basically what that says. So we're declaring a variable called text and we're adding the bold tags around the text. So now we're doing echo strip tags texts. So essentially what I'm doing is echoing out this variable with the HTML and the, and using the built-in function strip tags. And so it's essentially strip in the text that the boulder off of it, you notice this is not bowl. So if we come down here and making a declaring another variable called text2. And and so here I'm just echoing out the text without any protection with this built in function, and it actually shows the bold tag. So that's three of the common built-in functions. So what we'll do in the next lesson is our next lecture is we'll review some more. Okay, see you next lecture. 37. Common built in functions (Part 2): Okay. Moving on to the next custom-built or I'm sorry, built-in function. Alright, so the next one is called add slashes. So if we come here and add slashes, let me tell you what's going on here. So sometimes, you know, we have a single quotes in the name, like O'Reilly or kelley or something like that. And sometimes we want to escape that. This single quote here. So how we do that is add slashes. So what do I mean by that? So if we go here and we hit refresh, you'll notice with the ad slashes, it added a, an actual slash before the single quote here. Without the, the slashes it used, you notice it does not have the slash there. So that's kinda what as slashes does is it, anytime it finds a single quote, it will add a slash there. Okay, so the next one is called strips lashes though. So this kinda does the opposite. It finds it and strips it out. So if we go here, save and refresh. This is with the strip slashes. Because if you look in the code, you see that it has a slash here before the single quote. And it basically removed it here and here. It didn't not because I'm using the custom built-in function here. And down here. I'm not. So, so anyway, that takes care of that one. Alright, so the next one is called explode. Ok, this goes along with the arrays that we have that we've reviewed and past lectures. So check this one out. If we go here. Alright, let me explain what's going on. So we have a variable called Pizza, and we have all the individual toppings. Here. It's pizza, something we all can relate to. So the topping, what we're doing is we're exploding. Basically we're taking the string and converting it into an array. So if you remember from our previous lectures, we're taking, we have the explodes, so it's taken everyone that's using this comma and it's, it's allowing us to, you to reference it by as an array. So if we echo topping 00 would be pepperoni, topping one would be mushroom, and topping four would be the sausage here, because 01234. And let's, let's check it out. So for refresh, you notice pepperoni, mushrooms and sausage. That's how the explode built-in function works. Alright, so the next one we're going to review is called the implode. So basically what it does, let me post it here, I'll show you and remember, pause this video and go back and type these because, you know, the more you practice, the better you get. Alright, so the implode function does the opposite and explode it, it takes its input as an array and converts it into a string. So let's say for example, we have email addresses here and we create an array here of John, Jane, ad and Mike. And we want to kind of take those email addresses and we want to actually put them in line here so we don't echo single email. And what do I mean by that? So I'm saving here and I'm hitting refresh. And if you'll notice it's taken each one of these, um, email addresses from the array and it's just echoing them out here into, into an inline inland amount or different email addresses here. Alright, so another common practice is, of course, like we've seen in previous lectures, is to use the for-each. So essentially what we're doing is we're grabbing the email address here, which is has all the array items in it. And we're taking the variable here from here and as value. And I'm simply just echoing the value out. That's all there is to a for-each, as we've learned in previous episodes. So so when you go here, you'll notice it's taken each one of those and, and kind of going through the loop and displaying them all. So that takes care of the strip slashes. I think that's what I did in this lecture. Strobe slashes explode, implode. And yet they implode. So we're going to review a few more in the next lecture. I'll see you there. 38. Common built in functions (Part 3): Okay, what's next? So the next thing we're going to review in the common built-in functions is sometimes when you're building application, maybe you want to create a random number for whatever reason. So the, so the next thing we're going to review as something called rand, which is going to create us a random number says. So what we have here is we're going to echo rand. This is the actual ran random number with no parameters, and we'll see that in just a moment. The next one is rand, from ten to 20. So it'll, it'll display a number somewhere between 1020. The next one is 0 or one. You can have either or is what? It's basically gone and display. And the next one's going to display something between 102 thousand. So go back to that. And let's save and let's check it out. So if we hit refresh, notice every time that we hit Refresh, it creates different random numbers. And this can be, you know, very important inside your application. If for whatever reason you want to have random numbers, this is how you do it is very simple using the rand custom or common built-in function. Guys, if you hear me say custom, I'm sorry, it's, it's common built-in functions for some reason. I want to say that I don't know why. So, okay, so the next one we're going to review as something called string replace. A good example of why you would use string replace. Let's go back to you created a full arm. Let's say you're creative, creating a forum where people can actually post messages. So sometimes you may want to create, let's say, a white list of words that they say is, you know, a bad word of some sort that you want to replace that bad word would with something else. And that's precisely what we're doing here with the string replace function. So if you'll notice we've got a variable here called main text. And this pretend this would be the text that the user posted the message in the form. This is what they said in the message. So what's going to happen is we're going to receive the text from the form. And we're gonna put that inside of a variable and we're going to use the string replace. So essentially what this is doing is it's saying, okay, anytime I see an instance of this particular word, in our case is stop. That I want you to replace or along the function to replace that word with this word. In this main text here. So we ought to echo the actual replacement here. So to demonstrate how this works, I did a Control S or you do File Save. Remember, try to type this is going to help you. Let's go refresh. And notice this is what is appearing instead of the word stop. It. Instead. Did the inserted the word replacement. And this can be anything we could do. We could do, you know that for example. And and you'll notice it replaced stop with this. So works pretty, pretty nicely. And then that's what that's usually forward. You'll see a lot of that in people that build forums and things like that. Alright, so the next one is really, really common. One of the most common, let's say for example, you want to create a date. You want the date to display on the actual page. All you have to do is use the date function. And you can, I'll post the URL straight to the, what each one of these mean. Unlike obviously, the iamb is minus D is day, why is year our and then I don't know why they they put eye for minutes, but this is seconds. And if we save that, you'll see here it's showing the date and the time. And there, there it is. That's all there is to it. So imagine, you know, you want to display the date and time on your, on your site. Very easy to do. The next one we're gonna review is called string length. This was an important one to returns the length of the strain given. So remember, empty spaces counts as characters. So what I mean by that, okay, so if we do this and we want this to count how many characters is here. So if I did control S to save, refresh, come down here, it says 15. So if we take the spaces out, you'll see, it'll say 13. So you can see that the space is actually count. That is string length. You can play around with that as well. Let's move on to the next one. This one's called count. So it's basically for counting the items in an array, the elements in the array. So we've got 1234 and we want to count the number. So if we go here and you'll notice it says four. So if we add the say, you know, a filled one, let's call it, I don't know, tree, something easy. Okay. And we save and go back to here and refresh. You'll see it says file, exactly. So we can count the number of elements in an array. So that's very useful. 12. Alright, so the next one is an interesting one. It's called array combine. So it allows us to actually combine things in the array. So what do I mean by that? So let's say for example, we've got an array here, and we have an array here. So we actually want to combine green with avocado. So for one ray to the other and read to an apple and yellow to a banana. And you see that this is position 0, position one, and position two. So we're basically saying, OK, I want to combine a with B. And then we're going to print that out here for SC. Okay, go here. And don't worry, I'm all, I'm all not post all this code so you guys can follow along and see what I have here. So let's save and here. So green avocado. We've got red, apple and yellow banana. So thats array combine. Alright, and the last one I'm gonna review it, which, which we use that here is print. Our print r is used for arrays to print out things inside of an array, which you actually saw that evidence of that here, this is what print r does. It shows the, the results of the array. So if I come here and do print are, so it's kinda show the falling. What's this? So if we hit refresh, it's got a banana and be apple. So it's actually just gonna print out everything that's inside the array. So it works pretty well. I use this. I use for when you build an application, you want to see what, what variables are displayed or what's in an array. You use print r for displaying what's an array. I use VAR dop, a VAR underscore dump. I use that for just seeing all the variables and seeing a variable or are some variables. And I use just simple, simply use a you can say it, write a second. I'll simply use echo out to, to see variable values as well. So I hope this was very interesting. I hope you learned a lot from this. From this, from functions are about functions. So this concludes our function lecture. So moving onto the next thing we're going to review is my SQL. So we are going into database stuff. So see you in the next lecture. 39. Intro to MySQL: Hello there, welcome back. In this lecture we're going to talk about something called Massey SQL or some, some pronounce it as MySQL either way is fine. Basically what masi coal is, it's the actual database that you will be able to connect your application with to, you know, to bring out dynamic content. We also going to review some other things such as PHP, my admin. It's the actual user interface that allows you to control your, your database. And we'll review all that will also create, allow you to create your first database with PHP, my admin. And will create tables and insert data into the database. And we'll also review deleting tables from the database itself. So without further ado, let's move on to the next lecture. See you there. 40. Overview of PHPMyAdmin: Okay, now we're going to review PHP, my admin. There's couple of ways to get to it. To the PHP, my admin interface. Firstly, you wanna make sure is of course that you have your exam open and, and make sure that Apache is run in and mass equals r1. And hear a lot of times when I like to do is I like to just open up a browser tab and top in local host. Like some SCADA redirect you to the dashboard here. And you simply click on PHP mind man here. And we'll give it just a second to load. You can also get to it by clicking on admin here. And you click on it here. I typically don't do this, but you can. It's going to open up, you know, in this case it open up Internet Explorer. And it's gonna go to the same place. So whichever way you prefer is fine. But once we get in here, there's a couple areas I want to show you. On the left-hand side, this is a list of all your databases that you have. This if you click on the database tab here, you, this is where you actually create and what you will do this in a bit. We'll create a new database. This tab here is for SQL where you can manually paced him queries like you've ruined my select all from, from a table. You can, just by writing a query or various queries you can put in here. I don't use status too much. I guess maybe just stub, just some information in regards to how the DB is functioning. Maybe I haven't used that user account. You can create specific users to assign to each database that you create through here. You can export. And the next time you can actually actually create an export. So if you have a database that you want to send to another server, you can export it here. And I'll export the entire DB. And you can add it somewhere else, another database somewhere. So and import. This is where if you do an export from here somewhere else, you can do an import. And the rest of these, I won't review the rest of these. You can take a look atom, but I don't, I don't use them very often. So that's the main part of PHP. My admin is being able to see the databases, create databases. And inside of each database, I'll quickly show you this. We can create tables. We can modify the actual table. I'll show you all that in the next lesson, we'll create our first database. I'll see you there. 41. Create your first database with PHPMyAdmin: Okay, now we're going to create our first database. So the first thing we wanna do is to make sure that we're in the dashboard here, for example, if you don't see this after topping in local host, what she can do is make sure that exam, make sure Apache is run in and MySQL running, which we learned in previous lectures. If you have any questions on that, if you have problems BY bombings, let me know, be glad to help you. Alright, so from here, once you are able to see the dashboard here, click on PHP, my admin. Let's let it load here. Okay? Alright, so to create a database is, is super simple. All we have to do is click on New. And let's, let's, let's name our database. This is what this field here is four for the Negro database, let's call it first underscore database. And for the correlation here, which is kinda like the encoding, what I always do and the most standard one to use is the UTF eight underscore, general underscore c. That's the, pretty much the standard one to use for that. Now all you have to do is click on Create. Okay, so after you clicked on create, you should see this screen here and your first database is created just that easy. So in our next lecture we're going to review how to create the tables for your database, which should be pretty cool. So I'll see you in the next lecture. And, and we'll get it going and thank you. 42. How to create table and insert data: Okay, let's create our first table. Alright, so what you need to do is click on the database that we named first database. And that's going to bring you to this screen here. So let's do a common, a common table. Let's type in user. And in case you have a user management system that you would, you would create something like this. Alright, so, so we want to have five columns total. So you choose file and click go, and you're gonna see a screen that looks like this. Don't worry, it may look a little confusing, but I'm going to explain it to you. So the first thing we wanna do is let's figure out the first one typically is some sort of ID. So we're gonna do user ID like so. Alright, so the second one, we'll come back to these types. I'll explain those in a second. The second one, list top in firstName, firstName, lastName, underscore name. And you can do this along with me as well. And let's do active. And the last one is date. Okay. Let's talk about the types. Okay? Typically, these are the most used ones here at the top, but I think that's why it's divided. The first one is stands for integer, which means it can only be a number in this column. Var, char means it can be numbers, letters, symbols. That's really probably the most common one is var. Char. Text is for a great deal of texts that like if you have a form that you create in some ice submitting post, it would probably go on a text, a text type, and date as common. Some of these, I'll explain on kinda quickly. The to10 INT is four. For integers. Force at all of these get, it gets essentially what it is is for holding more and more data. For example, I'll go, I'll review. Let's go to the, the tiny text. This will give me a good idea. So for example, the tiny text, it can hold about 255256 bytes. If you were to choose text, it would hold 64 kilobytes. Medium texts would hold something like 16 megs of text. And long text would hold about four gigs. I mean, you can read more on these, but typically the ones we're gonna be using this in this example is integer, var, char, Boolean, which we know is one or 0, and Tom stamp. So let's do it. So first one user ID is going to be an audio-only, and we're gonna put 20. So that means it can be up to 20 characters. Or 20 numbers. So the only other thing that's really important that you do own the Adi is make sure that under ai, which stands for auto increment, as you see when I rolled over it here, make sure this is checked that way it will and just click on go for this. That just means it's the primary key. It means that's what other, when you reference this table, that's usually what you're going to references the ID, the firstname. Let's choose var, char, and let's make this a 100 characters here. As how you have to do on that. Last name must do the same thing like that. And active, this is where we're going to choose boolean. Or the reason I'm doing this is say for example, you have a user management system and you allow people to login and logout. So say for example, this user as a malicious user and you want to keep them from logging in. Well, this active column, we'll, we'll do that and and you can change it if I want to change it. Let's say, let's say that the fault is, every time a user is created, it's going to be one. And whenever a user logs in, it's going to look at this table and look at this column for active. And it's going to see if it's one, if it's not one that can't log in and that's kinda how it works. So we'll just put one character here and the date. We're going to choose. To choose timestamp, OK? And we don't have to put in anything for length, for value, and we just simply hit Save. Ok. So now under first database you're going to see the user table. So here's where it gets interesting. So if we hit, we click on the actual database on the left side. And let's choose insert so we can insert something in there. You don't have to put anything for user ID because it's auto-increment and means you could actually put something. I'll give you example lesson. We'll put 20 here. Okay? So and lesser Joe, Joe Blow, okay. And active, remember I'll set it to one and the current timestamp. So we click on Go. So if we go back and choose Browse, you'll see we've got a user id of 20. Firstname Joe, lastName blow, active is one and the date. So let's say we want to add, add another user, someone click on user on the left. I'm sorry. We're already in the table, so click on insert at the top. And you don't wanna put anything. And what's going to happen is it's going to, this time it's going to be 21 because it's going to start from the last one and auto, auto increments. Let's say Jane Doe. And same thing, active. And if we go back to browse, then you're gonna see it incremented to 21. Firstname dj, jo, last name Doe, and active, and the actual date, today's timestamp. So, so that's pretty much all there is to creating tables. Now when we do our next, when we do a project at the, the, the, the course that we will create more tables and we'll kind of see this in action. But I kinda just wanted to show you how to create tables. And as you see here, it's super simple. The biggest hiccup I think is probably just understanding the actual table types. Then we went over which was the var, char, integer, timestamp Boolean, that kinda stuff. Those. I just kinda wanted to show you that the typical ones, you could always just do a quick Google search and find, get a defined list of what the types mean. And I'm going to try to post that in here as well for you or put it as an attached document or something in the course. So you can see, but, but that's all there is to it. So congratulations if you followed along and created your your database and table. I'm with me. So next, we'll review how to actually delete the tables from PHP, my admin. Okay, so we'll see you in the next lesson. 43. Deleting tables from PHPMyAdmin: Okay, so to delete that table is very easy. All you have to do is on the left-hand side, you'll see the database name. Just click on it. And we'll give it just a second to load. Okay, all you have to do is click on the, put a check mark in the box or the table that you want to delete. And go over here to this drop down, click the dropdown and choose drop. And it's basically and say, are you sure you wanna do this, execute the following query, and click on Yes. And that's all there is to it. That's how you delete the actual table. Very easy. So if you have any questions on this, please let me know. I'll always glad to help. Okay. I'll see you in the next lesson. 44. Introduction to Building a framework: Yes, we made it through all the fundamentals. I know that was a lot of information to grasp, but I'm hoping that all the information that I was able to include in the course, the fundamentals will definitely help you be a better PHP programmer. So, so I'd like to thank you, thank you very much for making it to this, to this point in the course. So now we're going to build our project. And our project is going to be a working, a template that you can use for future sites that you build small sites. It's going to be mainly procedural coding. Cuz I want you to get a firm grasp on the PHP concepts and how to build things. And until you move into like OOP and maybe in a separate course. But the things we're going to cover in this framework is going to be things like bootstrap, jQuery, CSS. We're going to connect to the database. We're gonna add dynamic content like minue atoms and things like that. So you're really going to enjoy this and keep in mind the just because I'm throwing things out there like Bootstrap, CSS, jQuery, Don't worry. I'll I'll help you every step of the way. So without further ado, we're going to move into building our project. All right, I'll see you in the next lesson. 45. Creating the structure and including bootstrap template: Okay, let's get started building your framework. Alright, so the first thing we wanna do is go back to your example HT docs folder. And in there, let's just right-click and choose new and folder. And in here, I'd like for you to just I'm type framework, like so. Okay. And then when we go back to our IDE, if you if you will or if you, if you, if you don't have it open yet to your ear, Visual Studio code, please open it now. So here we go to File, Open Folder. And in here let us choose framework. And it's like Folder. And of course there's, there's not gonna be anything in this folder yet because as you see, we haven't put anything in there and that's okay. We'll give it just a second. Okay, so we see we have framework here. So the first thing we wanna do is let's create a new file. And let's call that file index dot PHP. Oh, and by the way, makes sure that you have your examp running as well. Make sure both of these Apache and MySQL started should be highlighted in green here as you see. So, alright, so we have, we have the basic or we have the structure. We've started the structure for the framework here we have an index which is going to be your first page. So now let's, let's go to, or let's type in Bootstrap. Like so. Okay, and when we click on that first link here, let's look on examples and learn a little slow, but okay, so this is what's cool. You can actually choose your layout here, but the one that I like to use, it would probably be the framework. So this is what it looks like. So all we have to do is let's right-click and let's choose View Page Source. And let's holiday or copy all the code. I just did a control a for all and you can do, you know, select all here. And I'm going to do control c for copy. And then let us go back to our index here. Unless DO control v. So which is for pasting or you can do edit paste. So the first thing we do, let's take out this fav icons because I don't think we're gonna need that. Let's also grab the, what is known as the CDN for Bootstrap. Bootstrap is down here. Let's see. Yeah, bootstraps here. So let's go back to your browser and let's do boot strap. Cdn. Okay? And once CDN is basically they're hosting the Library for Bootstrap, Dan jQuery and all that. So when you go here, let's see this CSS file here. So let's copy this. Let's go back to the code, and let's go up to the top here. And you'll see it says Bootstrap core CSS. So let's replace everything in between the double quotes with this and want to save it. And then we'll go back to here and choose the, the complete JavaScript that Bootstrap here. And let's go down here. And we'll see this between the double quotes here as well. How loud everything and analysts save. Okay, now, if we open up our browser And we've got localhost, Do you remember what to put here? We would actually put forward slash framework. Okay. And, and look, we actually have the starting of our, of our framework here. So a good way to check to make sure that everything is working in regards to the CDN that we just copy the CSS and Bootstrap is when you go here and you view source. If you click on this, you'll notice it didn't. It gave us the code as opposed to NOT_FOUND. If it said not found, then there's, you know, there's a problem. So that's the good, good, that's the way I always test. So if we come down here and we click on Bootstrap here, and you'll notice that's working as well. So we're good there. And I think this has something called a starter template dot CSS. So let's go here and click on the starter templates, CSS. And I'm going to copy this to control a and control C to copy. And let's add some more things in our structure here. Lists, and let's do New Folder, and let's name it CSS. And new folder, we'll name it JS. Okay, so we're kinda separating the JavaScript files from the CSS. So here we'll open up our, we'll click on the CSS. And I think it was called starter dash template dot CSS. Okay. Starter dash to implement CSS. And let's paste what we had in here. Let's go back to, and I also say that by the way, and we have to put some CSS here because we want to tell it it's inside the CSS folder. So let's go back and check it here. And you notice how that moved, but that that's telling me that the CSS is actually working. So let's go here, the view source a, and let's click on it, and there it is. Now keep in mind, you can do this as well if you'd like to. Instead of using the CDN, if you go here and you copy all this, and then you go back and you create another, another CSS style sheet in here. And you can name it Bootstrap, main.css, bootstrap.min.css. And you can put it in here and use the same path as where we used here.css forward slash, just like this, but it'll be a different name for this CSS line here. And you can host it locally. You don't have to have the CDN. Cdn. I just did it the kind of saved time. Alright, so next we will start separating the content in this template. Okay, we'll see you next lesson. 46. Separating header and footer: Let's go ahead now and start separating the header and the footer. Alright, so what we wanna do a beginner on the left-hand side, if you right-click here and choose New Folder. And once you choose New Folder, tap in, in C here. And let's right-click or lists actually expand it and choose New File. And let's name it header dot PHP. Okay? And let's also create another one called footer dot PHP. Alright? And so let's go back to our index file. And let's ground everything. Starting here, the DOCTYPE, all the way down to, let's say, I'll usually get the body to, that's usually the parts I get. Let's do x or a cut on that. And let's go to header. And let's do that. I know what, we're just putting HTML so you can, you name the page dot PHP to get it ready to accept any PHP syntax page. But for our analysis HTML and it worked just todd, Let's do save on that and then go to index. And at the top here, let's open up PHP tags. And let's do, I always like to do a few spaces here. And this close it, the PHP tag. And let's do require underscore once dot PHP. And this c, I'm sorry, what am I saying? It acquire once. And then let's do single quote. And let's type in I and C forward slash header dot PHP. Okay? And let's take the space out and let's save it. And then go back to here. Let's make sure all this stays, which it does. And you can see this is work in by, let's say for example, I'll name it something that's incorrect here. Like header to which we do not have a header two. So what's kinda happen as it should give us some type of error it does. So we know that we're separating that that had her out now. So let's do Save and lets, lets actually copy this whole thing. Well, before we do that, let's go down to the bottom and where it starts with this bootstrap core JavaScript. Let's copy all that and cut it. I just didn't control x. So and then go to footer and less paste that in there. Save. And then we'll go back to our index. And we'll go back up to the top. It will copy this. And then we will go to here and we'll paste it. And let me straighten it up a little bit here, okay? And just change this to footer. You kind of see how this is working. Okay? And same thing with here. We hit Refresh. Now it all seems like 11 page. But the neat thing of it is, is it's sort of like a puzzle, right? So you're inserting the individual pieces into it. And if we right-click and view source, you don't, obviously you don't see the include, but it does include the content for each individual piece. So this is actually what got me started in PHP many, many, many years ago was this concept that you could include different pieces. Before when I first started out in the early days of the web, it was more or less, you created that first page. And then to create, let's say for example, you had ten pages. All ten pages was essentially just a clone of that first page. So I would how they come back and say, hey, I want to add something that additional menu out on more navigational navigation item. Or let's change out the logo. Well, you can imagine the struggle there because I don't have to go through all ten pages and replace that logo or that navigation item and it was a pain. So once I learn how to do, the require or include is basically the same thing, we're requiring that for it to work. So I'd just do it did include I'm sorry, I require instead of include. And that works that works great. But they both function about the same. So you could have used include there. What actually what I'm referring to is here that could have been it'll work just the same. Just do it. Include Glaxo. And we go here and we refresh. You notice that we don't have any errors or anything. It still works the same. And if we view page source, get out to the bottom, there's the include part. So as you see, it works pretty well. So we'll move on for more fun in the next lecture. Thank you. 47. Making a connection to MySQL database: Hello and welcome back. In this lecture we're going to discuss how to make a connection to a MySQL database. So this should be a pretty fun lecture. Ok. So the first thing we wanna do is obviously, we want to make sure that your XAMPP or XAMPP is running. Make sure Apache MySQL running. Next step is to go to the PHP, my admin. And if you've forgotten how to do that, all you have to do is go to local host. And then that's going to take you to this page provided that exam is running. And then go to PHP mind me, end here. And should load up your DB, all your dBs here. So next thing we wanna do is we're going to go here, back to the code. Will your, you know, make sure you have your Visual Studio Code open if you don't. And inside this I-N-C directory that we made, right-click and choose new and choose New File option. And then type in create a file called db connect dot PHP. Ok, I. So in here, what we wanna do, the first thing we wanna do is we want to create some variables, won't declare some variables. So we obviously have to open up our PHP tags and clothes or PHP tag. And let's say the first ones, the first variables can be called server, name equals. And let's type in localhost. Let me explain the local host. Local host is basically, if you're developing locally on your system with like XAMPP, it's gotta be localhost. And many times when you upload it to a host, that setting is going to be remained the same as well. But sometimes when you are hosting with some web host out there, they may get you to change that to something else, but most of the time is going to remain local host. Alright, then we're going to create another one called username equals. Username, for example, is always going to be root. And I'll show you that in a second. Next one's going to be called password equals. And when the exam, the passwords is going to be empty. So you don't have to put anything in there. But again, when you, if you upload this to a host, you have to get the user's name and password for the database. Obviously you couldn't leave at root and, and an empty password because that would be easy for a malicious person to take advantage of. Alright, so password and DB name equals, okay, this is where we need to create our own database for our framework. So let's just name it Framework. You can name it whatever you'd like, but I'm just going to name it Framework here. Okay? And let's just do File Save or I do control S to save it for right now we'll leave it at that. And let's go back to the browser. And let's choose nu. And this should look familiar from the last lecture. And we're going to name it framework, like so. And remember for this, we're going to do UTF eight underscore general underscore CI right here. All right, and we're going to choose Create. Ok, so the database has been created even though we don't have any tables there yet, at least it's created. Alright, so the next step, let's go back to our editor and let's actually create the connection. Like so. Okay, so we're going to declare a variable called Khan. And by the way, this is called the MySQL procedural way of doing it. There's an OOP way and there's also something that's pretty much it became, this has become the standard in making a connection is called PTO, which is the most secure. But I'm showing you this way because, because this is the easiest way to actually learn it at this point. So then my SQL, el underscore connect. Ok, and then we're going to bring in all the different variables here. So we have, we have server name here and then username. The next one is password here. And the next one is db name. Okay? And then we're going to here, alright, and so rot. And after this is where we're, we're going to actually check the connection like this. Okay? We'll just do an if statement which we've learned about if statements. And we're gonna do if not Connection CON in our khan. Ok. And let's just put dy by spell it right. Dy and then C. And then connection failed. Okay? And let's see, connection failed. And then we will tell it, will get it to tell us why it, it gave lots failed. So you can do that with my SQL. I connect error. Okay, that should do it there. And let's see, and then we need to actually close the connection. So let's do my SQL, ie. Close. Okay. And then, okay, so a, we're basically opening up here, making a connection and then we're closing that connection in case you have another connection that you open up somewhere in your code. This will close it for this instance here. So let's save this. And let's go back to our header. And our header rot above the doctype here. Let's open up a PHP tag. And let's close it here. And close it. And let's do require once. And unless, I mean just single quotes, and we're gonna name it DB connect dot PhD. Ok. So what this is gonna do is we put it in the header because a header is going to be used through the entire site. And what's going to make that connection to the air's gonna call this db script here. Adb Connect script to always remain connected to the DB. So the interesting part of this is, you notice that we don't have an i and C in front of it. That's because this header is within the same folder. So we don't need to add i and C because it's the, the, the file DB Connect is in the same folder as the header. So you have to do is put divi connect. So if everything works fine, then what we should see here is we should, we shouldn't see anything, but we have a syntax error and that's okay. It's good way to troubleshoot it. On line 14, it says of DB connect, think it wants. Let me verify that. Yes. Okay. And line 14, let's see, should be I got to meet any of these here, open and close, and that should do it and semicolon. Okay? So that was a good thing about troubleshooting. It tells us what land, even though it said 14, sometimes you look at the line above it and there's something wrong in there. Okay, so let's go back and let's refresh. And now says is expecting, I mean, look at it again. Alright. See connection failed here, dot MySQL connect error here. Here. Hmm, let's see. Ok, I think I'll see it. Actually lets remove this here because I had an extra one. Ok, let's save it and refresh. Yea, okay. It's connected, but how do we know it's connected? Here's how you can tell. So what we do is we go here and see this f statement. If It's not connected, give us, give us this error message, right? So what if it is connected? So let's do else. Echo and DB is connected or whatever you are run in here. And watch this. So if I go here, refresh DBS connected. So we made a successful connection to the database. Yeah, it's awesome. Alright, so what I would do and that is I will just echo that. I'm I'm sorry, comment that out. So anytime you want to troubleshoot it, you think, well, It's not right. Let me check. If a got a connection to the DB, All you have to do is uncomment that save it. And it'll show you whether it's connected or not. And we can also tell this as work in to not only because it says it was connected, but if we change this to something that doesn't exist, a database that doesn't exist. We can hit refresh and notice it says unknown database, so we see that it's making a connection, which is great. So here we saved it, refreshed and we're back to square one. All right, so now we're going to work with that connection in the next lecture. See you there. 48. Building the pages: Okay, before we start interacting with the database, I think the first thing we need to do is probably create some additional pages. So let's do this if you will click on your index dot PHP file and go up to selection and select all or you can of course do control a on your keyboard. And let's do edit, copy or control C. So I'm sorry, I'm so used to using shortcut keys and that's why I keep saying that. Alright, so, so I'm going to go to here in underneath the index dot PHP. Choose new file, and let's name it about dot PHP. The Thousand and will create here are pretty much this is kinda the standard files that Mozart's use. But when we go, when we create the About Us, just do right-click and choose paste here. And for now we'll just choose save. Before we do that I'm on just but you don't have to type this, but I'm going to go in and put about here. Next. Let me save this. Next. Another common one would be services. So a right-click here, choose New File Services. Dot PHP. Same thing as before. Control V or edit paste. And I will just fry services here. And we'll say that another one would be, let's say products. Products will be another common one. Dot PHP. Ok. And I did totally did not smell that Greg's correctly. So let me put this in here. Products. Okay. Same thing, control v. Alright, and we'll put products. Do you see Ts? Okay. All right. And one more would be contact. Okay. And same thing. Paste that in there. I'm just put that there temporarily at the top so we can kinda see, alright, so after we have everything saved, the first thing we wanna do, Let's go to about dot PHP. And C appears lists do contact. Contact. Here. Let's do one more services. I think I've made it services. Yep, services. So we have the basic flow in the basic pages now. So next will interact with the database to create our menu items at the top. Okay, I'll see you in the next lesson. Lesson. Thank you. 49. Create menu database table: Okay, in this lecture we're going to create the actual menu table. So the first thing we need to do is obviously open up your PHP, my admin, and then click on your database on the left-hand side. And for the nameless top in menu. And let's give it five columns here and click on go. Okay, so on the first column here we're going to name it link underscore ID. And it's going to be an integer, and we're going to have 20. The length is going to be 20. And let's make sure we click on auto increment here. And then it's gonna say, you know, this is Primary Key, Yes. Next thing is we went to the next one. We'll name a link type. And let's do a varchar and we'll just do 100. The next one is link underscore title. And let's do a varchar. 255 to 55 is usually the most length that you can add in this field. I didn't think the length tight with ever get up to a 100 characters long. So I just are to hit 255 characters long conscious shows a 100. It'll never get up that high either. But I just thought I'd add it in there. Link total is 255. And the next one should be link URL. And I'm also going to make that 255. And the next one is blink underscore position. Okay? And we're going to make that an integer. So that means it's just going to be a number. And let's do 20, for example. Alright, we'll click Save. Ok. And so that is our actual menu here. Alright, so we don't have anything in here yet, so let's go ahead and add a couple. So just click on Insert. And you'll see it has all the fields that we created here, all the columns that we created, and a link type, let's put main. This is for example, if you want multiple, if you have multiple menus on your side. So I like Assad menu in a top menu, maybe a foot or menu. This is a way we can distinguish that. Alright, so link title, let's put home. Link URL is just put a forward slash here, and link position is one. All right, so we've got to have a way to actually assign how the menu items are going to display. And I'll show you that a little bit later. So this one here lists to about link type. Main. Title is about us. Link URL just put forward slash About dot PHP. Remember that's what we named our page. And the position is two. Alright, so after we do that, let's click on go. It should add both of those. So let's go back to browse. And there's both of those. So let's, let's insert some more here. Blink type main. I'll put main down here as well. Link title. I think our pages are contact products and services. Okay. So this next one will be contact. Make sure we put that capital Contact Us. Contact dot PHP. I should have put the forward slash in there. And link position is three. And this is going to be products and Ford slash products dot PHP. And this is going to be four. Okay? And then we'll need to add, you need to add another 11 more. Okay? And it's going to remain link title is services. And you can name this whatever you like here. Okay? And then forward slash SERP, cbs dot PHP, and this is going to be five. Okay? Alright, browse. So now we've created our table and we've created our columns here. So this is all the different links that's going to be there, and also the URLs and the position. One thing I'd like to add for this position here, and I think I'll do it will start at one and always put a lot of space in between here, maybe 20. Make this 30, and this is 40. We won't ever use it, of course, in this demo, but you may use it later. A lot. Wanted i do it, do this. Okay? The reason being is because say for example, we're going to add some more links instead of constantly change in these numbers here. We can add, you know, a good what, 18 more links between home and about us, and about nine or eight between about us and contact us and so on, so forth. That's why stretch those out. It'll still look at the position as this is first, this is second, this third, fourth, fifth. So works out well. Okay, so next we'll be working on the menu itself. All right, see you in the next lesson. 50. Creating dynamic menu (Part 1): Ok, let's work on the dynamic menu now. So we weren't looking at this. We basically won't this whole bar here. But we want it to end a menu, maybe a menu file. Because we're in, in, in the same problem as, as I referred to in earlier lectures about. We've copied the same page, the index page over and over again, which, which actually added the menu for each pays. That mean we, that means we'd have to go to every page and change it. So at this point, I think it's best under the include if we, if we create a new file called menu dot PHP. And we take all of all of this. Let's go to the About page, for example. And where it starts with nav here, all the way to the closing nav tag lists. Lists. Copy all of that. And you can rot, click and choose cut or control x as I do here. And save. And we'll go to Menu and we'll paste all of it in here. Okay, so the way this is going to work, first of all, it lists, make sure it works. So if I go here and I'm on the about page, we're not going to have a menu when we, when we refresh save, the menu disappeared. So we want to actually include that menu now. So what we can do is, well this, I'll just put include for this one. And menu dot PHP. Okay? And we'll hit Save and now refresh. That mean you should come back now. See include menu filled up a stream about LAN three. Mean you, oh, we forgot to put the include here. So in C, like so. And now our menu should reappear again. There it is. Okay, so now in our menu file, we have, we actually have all this. So really the only thing we need out of all of this would be we need to, we need to modify this line and add some code to this PHP code. So the rest of this we can pretty much take out, right? Because we don't need any of this stuff here. So ultimately what it's going to look like as we save it and refresh. And all it's gonna have is gonna contain these two. But let me remove, let me remove this line because we don't need this one either. Alright, let's save. So notice we got home here. Alright, so we got a good start. So what we can do now is we need to start writing some PHP. So right here, let's open up our PHP tags. And let's actually close the PHP tags here. Tag, here, PHP tag. And let's The first thing we will do is we want to start the query. Okay, so I'm commenting, so you kinda see what's going on. So let's go to this URL. Here. Equals Select. All right, so we select and we add a star for selecting everything from the menu. And we're going to order by space, by, I hope your top along with me, that's like I say, it's a better way to learn by doing that orderBy link position. Okay? And let's see, they actually need to put double quotes around it here. Okay? And let's see. So from here, now we're going to check the query. So we're gonna do here, and we're gonna do an if statement unless they're okay. And we're going to do if result, result is equal to my SQL el I query. Okay, and then we'll open this up and do connection meant remember the connection was from the DB connect screen. So I click on that, that's where we're getting that variable here. And which reminds me Wilfred and the menu we're, we're not connecting to this db connect. So I'll come back to this in just a second, but we need to, to do this. Actually required at k db connect, dots PHP. Okay? Alright, and now let's go back down to here. And Republic I think gets a comma here, SQL query, like so. And the n, We're going to fetch the results now. That's the results. And let's do a while loop. If you remember from our previous lectures we talked about the while loop. Okay? So we're going to make the row equal to MySQL. Fetch associates, associate that associative array is what this means. And then the result. Okay? And let's see at this, okay, and we're going to declare a variable called total equals. And we'll declare another variable called link like that. Ok. And for the total bless do row. And then we'll OK this double-quotes link title because that's what we named the column here. And we're gonna do the same thing here, were not put rho, rho link URL, URL. Okay? Alright, so we're going to continue on with the rest of the connection and everything. And the next lecture will see you there. 51. Creating dynamic menu (Part 2): Okay, let's continue on. Alright, so we have the while loop here. The next thing we need to do is we need to simply do need this line here and cut it there and put it here. And then we can do an echo here. Let's start out with double-quotes. And anytime we have double-quotes, We have to escape the double-quotes within here. Like so. And like this, this. And I'm going to get rid of all of this stuff. Leave this and then we'll have to end it here. Is it all right? And then what we need to do is we need to take our variables. This is the title. So the total is going to be out here where it's going to be at the actual name of the of the pain that the menu item. Okay. And then we'll take link and we'll put it right here. Like so you see, what I've done here is a basically I kept all this stuff here, which reminds me I need to close PHP tag. Now we've got all of this here, which is just straight HTML. And then because we need all this for the styling and whatnot for the bar itself. And then here we're actually querying the database to get the actual total in the link. And we're surrounded by link position. So when we go here, the next thing we need to do is, well, let's, let's free the results. It okay. I like the type it is coming. Free result. And basically what this does is it frees the memory on the results set here. So basically just cleans it. So it's a good practice to do this. Okay. Let's see. Okay, and the next thing we wanna do is we want to go down here and close connection. And while I'm thinking about it, I'll, I'll meet up this first. Okay. And lead the connection in there. Okay. All I'm thinking about it, make sure in the DB connect, let's remove this here, this, this close here because what's happening is closing and it's not allowing us to do, it won't allow us to do the query here. So let's go back to menu here, and let's take a look to make sure everything looks okay. And that's fine. Fan here. See here. Okay. Here. Yeah, everything looks fine but we'll test it. Okay, so we go back to about and we have the menu in there. So let's see what happens if we've got any topos or anything like that, which is very possible. We do. Couldn't fetch MySQL lie in mean you land 17. So let's look at that. Let's see, 17 says something is wrong here. So let's see. So to hear, results equals MySQL query. We've got the connection here, we've got the SQL query here. To open parentheses. Let me go back, maybe go back to DB connect. And then you make sure you have thought I'll remove this, save it. Let's see, this refresh. Okay, we're bringing on the end, but we've got this other weird error on line 22, Admin you. Alright, let's see. Okay, link. I misspelled it here. So that's the that's the beauty of, of, you know, CNN what line and troubleshooting because you'll, you'll do a lot of this, alright, as save it again and see if you're getting more problems. Fatal error. Line 29, C 290, I'll see, should be MySQL, I free result. Save. Ok, there we are. Now we've getting our mean you straight from the DB, the menu items. So the C contact. To figure that one out and see I've got some problems here. Okay, let's go and see if we can straighten that out. I think it must be Framework. Food sash. Alright, so let me copy this here. And let's do the same thing here. Yeah, but while we're at it, I'll show you. You can, as you see him what I'm doing here. You can modify this sail directly. Just solve problem here. So let me take this out. K, c. Okay? All right, now let's go back to the page itself and refresh. And that should take us to contact, but just showing the old menu because we need to update the menu like we did on the about us page. I want to see one more problem. Ok. See, this should be a framework like so. Okay, go back to here. Let's refresh and go home. Yep. Okay, so we've got all the menu items appearing from the database now. So now in the next part, so the next lecture, we're going to go through and fix all these pages to show the same menu. Okay, we'll see you in the next lecture. 52. Creating dynamic menu (Part 3): Okay, let's do the final piece on adding dynamic menu items. So we have to modify these other pages to be the same as the about us page. So as we see here, we're basically just included the menu.html. So it's as simple as going through here and removing from the beginning now to the closing mouth here, hollow audits and I'm hitting delete on my keyboard. And we'll save that. Let's go to index. Do the same thing. Add, edit here. Let's go to products. Less removed the old nav list, add that. Let's go to services. Do the same thing. Okay, let's add our menu. Okay, now, I think that's everything. So let's go back to here and lets you know what that's, that was the bootstrap. Let me refresh. Okay. So we go home. Minuss the same about us, the mean, use the same. Contact, menu's the same product, also the same, and services the same. So all of them are done now where we have a total totally dynamic menu system from the database. So what we're gonna do here is I'm going to show you how this link position work. So let's say for example, we change our mind and we want services to be in second place so we can choose any number between 120. So we'll, we'll put ten here. Okay? So now what you're gonna see is you're going to see the services is going to be home and then services. What's this? See it. Move the services to their that's precisely the reason that skip something you numbers in between. So we can always change it if we needed to or not. So it's not so limited on the amount of amount of numbers in between. So you get even space it out more and you could do 107,000 whatever. And that's would probably be a good idea if you had a large side, but for, you know, for our small side shouldn't be a problem, but you can kind of see how it all works now. So, okay, so now we're work home adding some dynamic content to the, to the actual site. Okay, we'll see you in the next lecture. 53. Changing the link url: Hey, welcome back. Something I noticed. I think it's gonna be a lot better to actually move the project name outside this link URL. And remember we had framework and then forward slash about slash contact products services. I want to add and remove that and you can just double-click on this sale and you can remove it from there. So just remove all the frameworks and then go back inside your code here. And I've just created another variable here called Project, which is framework is that's the name of our directory that we're working in. So when you create this variable, then in here, make sure you do a forward slash here, and then add in the project variable here and another four slash, like so. And then when you save it, it's gonna give us the same result as before, but we don't have that framework in the database. So as you see, we click on Contact Us About Us services, products, home, all that. Everything still works the same. And that's why we're, we're adding it here. So the reason it's important at a here is say for example, I changed the name from framework to framework two or three or whatever. Then my whole application with with essentially break because in the database it is, it would be all in all of these different links and that's probably not the best practice. So the best practice was maybe created a one variable. And then if you, if you change, if it changed, you could do that or, you know, whatever from there to match your directory or folder name that you have all your files. So I just wanted to throw it out, throw that out there. And so anyway, we'll move on to the next lecture. Thank you. 54. Building the home page: Hey, welcome back. So in this lecture we're going to actually enhance this homepage. Because right now it's like a little boring. So let's, let's add some, some, you know, some content to the page. So what we need to do is if you will go back to your Bootstrap page here. This is where we initially got the template. What you can go to getbootstrap.com, forward slash stocks, 4.146 examples or just simply do a search in Google for Bootstrap. So what we wanna do is choose one of these. I think I'll choose this carousel. So if we click on care cell immature, it has a nice carrousel. The background should be here so you can actually see yet, but we'll add that. And it also has these spheres here that we can add images in. And the content goes on down. I think it's a pretty nice layout. So what are we gonna do? The first thing is, let's right-click. Let's go down here to the white. Unless right-click endless view page source. And if you'll notice here where it says main, the opening main tag, if you go down to the bottom, you'll see the closing main tags. So we'll grab all of this content. All the way to here, okay? Okay, copy and paste all of it in here because you'll notice it's got the opening and closing main tag. So I'm gonna go in here and a C, I'm going to paste all of that, like so. Alright, so there's actually another step that I've kind of already done that if you paste it in there and you went back and you've reloaded the page. For me. It's you see the carousel but you probably won't see the carousel yet. You welcome to try it. And the reason being is because there's another piece here. If we right-click and go back to the source, you'll notice that there's another stylesheet called.carousel dot CSS. So what you can do is you can, when you click on it, you'll see this. And you can simply go File Save As or saved page as. And then go back to your exam, HH, HT docs, and go to framework and the CSS directory that we created in our previous lecture. You can double-click on that. I'll already gotten in here, but you can just go in here and and save it as.carousel dot CSS, like so. Okay, and then you make sure that this is going to work, okay, it should. It does, alright, and then there's one more little step we need to do. So we've added the.carousel dot CSS. Now we need to go to our header file because we need to tell the header that that file it actually exist. So all you have to do is copy this line here. Paste it here and then create your H ref, exactly like I have here, which is pointing to the CSS file and.carousel dot CSS, and you should be in business there. That's all you gotta do. So once you've got that done, it should look very similar to this. If you haven't problems with it, let me know, be glad to help you. I'll also include all the source code and everything. But to also, let's move on and add some, some background images and image make the, make the page look nice. So let's go back to our index.html. And you'll notice at the top, you'll notice this image class first slide, second slide, third slot and all that. And you'll see this SRC. So to save time, I've already added the images that we're be using in here. And molal means you're welcome to use your own images. But for the sake of learning this, you know, or just updating the actual homepage, you can just use my and to save time, but keep in mind when you develop new projects, you can add obviously your own images. Alright, so the first thing we wanna do is Let's do lake dot JPG. Okay? Alright, and don't forget we have to put our ING directory. If I didn't say it makes sure that you create an I-N-G directory and add all of these images into it. Okay? So it should look like, it should look like this. So these are our files. You should have a directory called ING and put all of your images in there. Okay? So the first one's ING lake dot JPEG. So let's see that. Let's go here. Let's refresh. And there's our first image. It looks pretty nice. So as we scroll course, we gotta add the other images. So the next one is going to be called City dot JPEG. So let's go here. And let's do IMG. Don't forget cd dot, JPEG, save. And let's refresh the page. And there it is. It's very nice. Okay. Let us go to the next one. And the next one is going to be servers dot JPEG. As matter of fact, I'm just going to copy this. It makes it a little faster. If we do this, copy everything in between the double-quotes and delete it, and then paste this and change that to servers because we'd have servers dot JPEG. Let's see, RBRVS, okay? And that should take care of all of our, I just did a control S on my keyboard. By the way, you can do file right here. You can do File Save, just did control S to save it. Okay, so let's refresh. And there's our first one, there's our second one, and there's our third one. Looks pretty nice. Okay, so let's, let's add some content or images inside these spheres here. So let's go down here. Let me scroll down. Alright, so this should be the first one. And the first one is, let's see, Girl one is what I named it. So again, let's go here and paste this in here. And it should be named Pearl Harbor one. Okay, let me take that out. Is that okay? Okay. And this next one is going to be girl to okay. The next one should be business underscore main.js, jpg. Okay. I'm want to say this and we can check it out. And let's refresh. There they are. Okay, so we've got those images in internet. So that's awesome. All right, so let's add these images here where it says generic place holder images. Okay? Alright, so those are gonna be listed down here. Alright, so the first one, I believe is going to be party dot JPEG. So let's go, right. So you're gonna see lack on mom 10, eight here. You're gonna see this data SRC, just remove this data because we don't need that. And then put in our paste what we had up above unless DO party. Let's see, party. Okay. That should be that one. Let's check it out. Fresh. Actually, I did it in the wrong spot here. I was supposed to add it here. So let's take this and you can keep it there if you like, and put the other one and the other other place, it's fine. Whichever one you all do, that's party. The second one is drinks. This C k, And let's do that to go and do the third one, which I believe is checkmate, checkmate dot JPEG. So we go here. Checkmate JPEG. Okay, that should be all of them. All right, so let's refresh the page. So we should have all of our images. Now. Let's see, we've got one. It's not showing up that first one. And this one, hmmm. Let's see what's wrong here. Checkmate, checkmate dot JPEG. That's gotta remove the data. That's why I will say, and we've got to remove that. And remove this. Okay. And let's refresh the page. And there we go. I think we have a decent looking page now we're going to add. And that's pretty awesome. Okay? Alright, so we will continue on in the next lecture and we will keep adding onto the site. Alright, we'll see you in the next lecture. Thank you. 55. Carousel Styling: Okay, and just notice this, this gap at the top and it's driving me crazy. So let's go ahead and fix this. So what you do, I don't know if you've ever used Web Web Developer Tools or not, but we're about to use it now. So all you have to do is, let's Basically what I wanna do is remove this gap at the top, so it's all seamless. The background image with the header, the nav bar rather. Alright, so what I'd like for you to do is right-click here and the shoes inspect element. And that brings up our Web Developer Tools. Alright, so we wouldn't look if you'll notice when we run our mouse over, over the different classes, you'll notice that things are highlighting and whatnot. So what we'll look for though is this carousel enter right here. This is kinda the main class for, for the movement of the the carousel. So if we click on that, highlight it, you'll notice it says carousel dash enter. So what we can do is we can put on top. And then we could do negative, say 24 pixels. And you'll notice it brought it up here. So that's kinda just a test to test it on the fronting and doesn't really change the code. So now let's change the code because if I refresh, go back, you'll see it's still there. So what we can do is let's go back to the.carousel dot CSS. And if we don't see the carousel dash scanner, which we don't hear it even when we scroll down. It's not, it's not there. So let's add and the care cell dash enter. So let's add a dot c, a, r, o, u, SEL, dash, enter in ER, and add a curly brace for the space there. And let's just simply add top, just kinda like we did in the Web Developer Tools, negative 24. And what that's gonna do is that smooth in at negative, so it's going to move it up. So positive would be and go back here. Hold on a second. So if we added a positive number that would push it down, a negative number is pulling it back up to the top. So now when we went in here and we added it to the style sheet.carousel dot CSS. And I did a control AS or you can do File Save. Now we go back and refresh. And now it moves up. So I think that looks a lot better. Scroll up here, that it's all seamless. I think that's a quantum improvements. So anyway, I just wanted to throw that in there. Okay, see you in the next lesson. Thank you. 56. Building A database driven products page: Ok, let's work on the product page now. So let's click on products and it's just the base, the basic template that we added earlier. So I'm gonna go in here and I'm going to grab some sample HTML for products page I found online. I will include all this code by the way. So if we go here and let's go to our products page here, and this is where the starter template. So Let's take all the way from the main, all the way to the main, take all that out. And let's paste all this in. And I'll show it to you here. So it's basically all the products. You'll see that it's going to be in, in columns, two rows, three columns. Let me scroll down and show everything to you. Okay? And we save, and it's going to look like this. So which is not bad. So what we wanna do is turn this into a database driven products page. Alright, so what we wanna do is also cut down on all this code. Because here's the way I look at it is each individual section here. Let's take this first one here. Hp's or H, a column here. This area right here should just be repeated every time. So that means we don't need all these different ones because they look the same. You notice this here. See all this thumbnail cards, the same events, the same, all of them are the same. So what that tells me is I needed some sort of loop that then I can just loop through completely. So let's do this. Let's go here. I'm going to take all of this out here. And let's go down to let's go down to this one. This one here. And I think that's actually too much. Okay. All right. And let's take all this out. Here. I'll leave the last two closing deals because those are the ones that's going to match the container close, going to close the container and the row. So if we do save here and we refresh, so we just have one. So that's going to work out perfect. So now what we need to do is we need to change this, convert this to PHP while loop. And so basically, the first thing we wanna do is we don't want to be in, you know, we don't want to include the container in the row because that's the overall. What I, what I think of as the outside of this, everything out. That's a outside. We want just this piece here. So that's just this code here. That's all it is. So let's move this down so we make some space. Let's open up our PHP tag. And let's close the PHP tag. Like so, let me move this over here to match that one. Okay? And let's go here. And let's start the query. This is going to match what we did in menu here. So let's, let's copy. Let's copy all of this. As a matter of fact, let's go ahead and take this out as well. Just remove that. And let's copy everything that within the PHP tags. So we'll do this, copy and go back to here products. Alright, and just move this down for now. Alright. And, and so we're going to create a table called products. So we can just select everything from. Products. Will locate that in the next lecture. But I just want to set it up, get it ready. So we now we don't need this. I want you to pay attention to this here, the dollar sign row and then like link URL, link title things out that pay attention to that because we're gonna be using that again. So we wanna take everything out of the while loop. And I'll copy all of this. And let's just, I just did a control x. You could do edit, cut. There. Let me take all of this out. I'll these bases, alright, and between the opening curly bracket and a closed, close one. Let's add this in here and we want to do an echo. So if we do echo, we need to do a single quote here. The reason we do single quotes is because see all the double-quotes all in here. If we did double-quotes, we'd have to escape by doing this to every single one. So I think we're going to use the single quotes. So we opened a single quote and now we need to end a single quote here. Okay? And that should do it. For, for that, let's see. Let me check. I saved it. Let's say it's probably gonna give me an error message. Yeah, because I don't have the database yet. So let's go ahead in the next lecture and create the table for Cal products. Alright, see you next lecture. 57. Creating the products table: Okay, let's create the actual table now for our products. So if we go back to our browser and we go back to our database here, let's click on New under framework here. Give it just a second here. All right. And we don't give the table name. We're going to name it Products. Okay. And I'll hope in your follow along with me as well. It will definitely help you learn much better by following along instead of just watching if possible. So let's do the first style, ADI, or we have to make the first one has an ID. Let's do product ID. Okay, and we'll just leave that there for now. Title. But stew description. Let's do image. And we got one more to add, but we'll add it to in a little bit. First thing we'll do is integer, and let's make it 20 characters here and the links we, let's make sure it's all to implement here. And click on go there. The title, we'll just make it varchar 255. Description will make it text. You can put a lot of text in there when it's that image. Let's do just var char as well. And let's do 255. Let's save that. Ok, I want to actually adds after image. I want to add one more. Let's do price. Okay? And let's do var char 100. The fine on that. We'll save it. Okay? And once we go to products and click structure, then we will see the entire structure here. So what we wanna do is won't actually insert some data here that we can pull out. So if I choose Insert, you're going to see title description image, pick Armstrong price. So I've already added some images here. So what we'll do is add these images I edited in the image directory. And don't worry, I'll include all this code as well. So let's do tunnel candy one, and let's do the description. What, uh, what we need to do is call it something called lorem ipsum. In if you've never heard of it is really cool. And then I think I'm spelled it right? No, I didn't at l o 4m SUM. And basically what it does is it creates fill in text works very well. So we won't five paragraphs and we want it to automatically generate is all in Latin. But it's just fill it in text and you can come in later and patrol and texts. And here if you, if you were really building your own site based on this. So I'm gonna choose about this much here. Okay, let's go back to the PHP, my admin, and less. Paste that in there I did a control V or you can right-click and edit paste obviously. And for image, we're gonna put in candy one dot JPG, because that's what was here. Candy 1.jpg. Okay. And price, let's put $20. And let's choose go. Let's do about three of these. Give it just a second. Okay, once dig and so on. Okay, there we go. Alright, so we've got one, so let's insert a couple more. Sweat, a little slow. Sorry about that. All right, and we'll make this one candy T2. And we'll go back to Lorem Ipsum And we'll grab some, just some other texts right here. That's where I was copying the candy from before. Okay. All right, and let's paste that in there. And L2 candy to dot-dot-dot JPEG. Price S2, $30. For that. And let's click on go. And let's insert one more. By the way, I could have probably just scroll down, but I just did this white candy. Three. And let's grab some more. See here. Grab this much here. And let's put it in here. Okay? And this candy, three dot JPEG, okay? And lets us make this $15. Okay, go, Alright, so we will at least how the first, the top row. So what we can do now let's go back and look at our code again. And so we're selecting everything for products. We have products now. So it should, actually, we shouldn't get an error, but it should just show the normal HTML. Well, we're actually getting an error. Let's see. 18. C. That's fine. That's fine. That's fine. Let's see. Hmm, let's see. Let me go back to here and okay, let me make sure I remove this. This is a menu dot PHP and save, make sure that's not in there. And also not at the bottom here. So we'll save. And this, make sure I save menu. Save. Okay, and let's refresh. Ok. You see what, what happened here was basically we took, let me go back to products. We took all those different columns. That was the code that was there before, and we made it into one. And we're just using that while loop to loop through each column until it comes up to three columns just like this. That's all there is to it. Next will be replacing the image, the title, the description, and the price with the values from the database will see you in the next lesson. 58. Making the Products page dynamic: Ok, I think we've been doing a great job so far with the products page. Now let's make it a little more dynamic, shelly. Alright, so let's go in here. The first thing will do remember what I said in an earlier lecture in regards to remember this row here. So we're going to use the same thing here. So what we're gonna do is let's just copy this. And let's go to the products, the products page here. And the first thing we wanna do is probably, let's do the towel first. Alright, so this is, this is product title and it says it here, so we know that's going to be it. So let's do this. Let's take this and plot it and delete. And I'm doing control V. You can do edit, paste there. All right, and notice how it's the same colors. That means it would, it would not work this way. So since we have a single quote, let's take a single quote here and let's do concatenate. So that's simply the dot, single quote dot here. And let's do another dot and a single quote just like this. All right, and let's choose Save. Now we should get the dynamic title for each one should be Candy 123. Let's see if that works. Okay, so we got an error message lon 30. Let's see what's going on here. So it doesn't like that they've got to put a space here. Possibly. Let's see. Okay. Save it. Okay. Let's see. Here I know the owl mouth my mistake as supposed to change this. So it should just be titled. All right. So let's save. Yeah, I couldn't I didn't know what that was. All right. So we've got k2, k1, k2, and k2, k3. You see how we're pulling that out? All right, so let's do the same thing. Let's copy this. And let's do the same thing for, let's say description here. So if we take the current description out here and let's paste that in there and let's call this description. Okay? And save. And now each one of these should be different. And they are, you notice they're all different. Great. Okay, so the next thing we're gonna do is the actual price. So let's do this. Let's go here and delete that and Control V. I'm sorry. I'll remove it and then paste that in there and typing in price. Okay, and let's refresh. And you should see the process change. That's the same process that, that's in the, the actual database itself. So we can tell that by. Go into the products. Here, it just takes a second and you see there's 20-30 and 15. And back to here, 203015. So that's working. So in the next part is the actual images. All we have to do on that is where it has SRC. Here. Let's take out everything that's between the double-quotes. Unless top in Ay mg because that is our image directory here. And I'm gonna paste this in here like this. And let's type in image save. Okay, and let's refresh. And now we should see the actual images. We see the images. But there's another problem here. Notice how the, the actual images are different, looks like different heights here, and different widths. So what we need to do is we need to modify our CSS because I added the products CSS here. And but we wanna do is we want to create a new style. And I'll show you here. Put a dot PRO DEA image and open our curly brackets like so. And let's top-down height. Let's see, I'm do about 260 pixels. And let's do width, 395 pixels. Okay? And then the next, that's the first step. The next step we need to do is we go back to products and notice it has image class and it has all of this here. All we have to do is for the first one just top MP ROD, AGE and a space. And now save it, will come here and they all should now be the same size. Yep. So now they're all the same size. And that's all there is to it. You can actually go in and create, choose Insert. Make sure you click on products. Choose Insert and you can add your own, your own descriptions and images totals, everything. You can add it in. It. It will just show up, down below another column and you add three more and show up underneath that. And that's all there is to it. So now we've we've converted that product's page into a database driven Paige, I know you see Add to Cart were not really not doing a cart in this, in this in this class, I guess. Because that's a little outside the scope of what we're doing here. But you can remove these or whatever. Actually I can remove on, just go here and remove this open-end and close div tags. And here, and there it is. So maybe in another lecture, maybe are created another class. I'll, I'll maybe do a shopping cart or something, but, but this is mainly used for maybe you just want to display your products but not necessarily sell them online in this, in this course. So, okay, so next we will work on the services page. Okay, we'll see you in the next lecture. Thank you. 59. Creating services page: Okay, now let's work on the services page. So before we do that, let's review some Compton in your menu.html. If you're following along with me, go, please open up the menu dot PHP if it's not open. And because what I was noticing is this menu started messing up on me. It's really odd. And one of our previous lectures where we created the menu, all the navigation atoms across the top here. It just started messing up. So what I've noticed is I didn't have this closing tag. And the closing UL I think I had the closing lie outside of the while loop. Just make sure you add that here and makes sure that the closing UL, unordered list closing tag is here. Ok. So, all right, so let's move on the services. Alright, so what do we want to do about the Services page? I think we should go back to our bootstrap, getbootstrap.com, or you can talk to him. Bootstrap should lead you to this page if you type in Google. So, and you click on examples at the top. Okay, and then let's choose this. I like this processing one here. So if you click on the processing seconds taken a second. Alright, let's create a service page similar to this. So what we want to do obviously is we right-click and choose View Page Source and less grab. Just this part here. I think it's going to start right here. So let's notice this processing header, because what I'm looking for is the processing all the way to here. We don't, we don't want the footer information, we just want that all of this. So if we go in here, this is where the processing starts. So let's go all the way down to here, above the footer. And let's right-click and choose Copy. And then if we go back to our editor here course will take all this out here. And we'll paste and let's see what it looks like. Okay? And we'll go back to here. And this is what our page looks like and it's just that easy. Okay, so one quick thing we'll do, let's change this to to say our services. I just spell it right. Okay, and and maybe here let's put all our services. Okay? You can design this any way you like. By the way, this is just my suggestion in our, in our course here. Alright. So the next thing is we want to make sure that this, these two lines stay. I'm exactly like they are. We don't want them to be inside the loop. But what I also noticed outside here is if you, you'll notice when I run my mouse over here and how you see it repeats here, here and here. Same thing here. You'll notice it repeats. And all three. This does repeats all the way to here because the pro, free pro and all that's going to be different. But that's the same. So what that's telling me, everything's going to be the same. All the way to, to hear each block is going to be the same. The sorta like the products page. What we did on that. And so what we'll do is let's take below this second closing deal. Let's take all this out. All of this, okay? And we'll probably leave one of those deals at the bottom. Okay? So it should look like, should look like this. Let's see. Okay. So what we wanna do here is we want to save this. And let's go back and see if it just shows one, which it does. It shows one what they call panel, what is known as panel. So we'll come in here and let's go back to our product's page. And before we copy all this, now we need to do something else. We need to go to the actual database and we need to get that right. Alright, so when you go to, to the framework database, you choose framework. It's going to show the actual tables that we have and currently we have two menu and products. Will I included a file called service dot SQL? And you can download that. Let me know if you have a problem with it to save time. I've kinda already created that. So let's go to click back on structure less go to import. And this was going to show you the import feature. So it's really a cool idea to do this. So choose Browse and there's a services dot SQL. Let's click open and let's click on Go. And then it's going to import all, everything from the services table. And as you see, we have a services table. Now, let's click on browse. And this is everything that I've already added here. Alright, so let me know if you have a problem with that, but that should work just fine. Okay. So let's go back to here and let's go ahead and copy all of this from the products dot PHP page. Let's go to Services and rot, and rot here on line 15 or 16. Let's just paste that in there. But we need to also open up our PHP tags, of course. And we'll close the PHP tag right here, right before this close and D7. Alright, so. When we do that, let's change this to of course, services. All that shouldn't be the fun. We got to close this here. This is the for the while loop. And we need to another one. Down underneath it. This is the closed the if statement. And you'll see where it highlighted here and kinda highlighted here that say in that for that. So what you want to hit this, when I click on this one, then you see this one's highlighted. So i goes to show you that. Open the if statement. I closed it here, open the while loop, or a closed it here. Okay, next step is we need to actually do an echo here. And let's do a single quote. Remember we do single quotes because we notice all of these double quotes in here. And if we use the double quote here, we'd have to escape each double quote inside of the echo statement. So let's do another single quote here, and let's do semicolon to end it. Okay, so what we, what we should see now is we should just see, continue to see that one panel or I'm sorry. We'll see six panels is what we should see. Okay. Yep. There's all of our six panels. All right. Let's take a takeout this sign-up for free, because we won't need that. Let's take that out here. Okay. Move that over. Save. All right, so now we've got everything correct, except for now we need to import the actual a reference, the actual rows in the table. So let's go back to here. And remember in our products, remember we had this row image, for example. I'm going to copy, I'll tell you what, I'm just going to copy this. Okay. And we go to Services and let's take a look at our services table. So or services? Yes, sir. Sustainable. We got services, service tidal service description, service price. Okay. So let's go back to here and let's do the first one's going to be the actual title, which is going to be here. So the first thing we need to do is we need to open up a single quote and add up concatenation dot. And then we'll paste what we copied from products. And let's do another dot concatenate and a single quote. So that's kinda opening this up for the dynamic data here. So let's type in service title. Okay, and let's save that and let's reload it and we'll see. And there's all of our titles. Yes, looking great. All right. So let's do the same thing. I'm just going to copy the single quotes and the concatenation and all that's even kinda since you, since I've shown you that, then we're gonna go to the price. And let's leave that dollar sign. Just take out that little 0 there and do this and change that to price K. And let's reload, let's check it out. And there's our price. If you want to choose a monthly fee, you could you could do just a solid fee for each one if you'd like, just for services page four, however you want to design the services phage. Alright, so let's take out all these list items. This actually take all of this UL out unordered list. And let's do this and let's do service description. Like so. Okay, let's save that. I just did. Again, when I say, Say that I do Control S only keyboard by habit, you can do File Save. All right, and let's reload it. And look in there. It's got all of our description information for each one. So so I think that will complete our Services page. Again, if you have any questions, please let me know. But that's kinda how it works. We're we're kind of using the same functionality from the products page, uh, to, to also create the services page. So again, any questions? Let me know. If not, we'll see you in the next lecture. Thank you. 60. Create the About us page: Okay, welcome back. So let's work on the about page. I found a really awesome looking layout, bootstrap layout that I think would look great on this page. So let's go to this URL. You'll see this URL here, URL here. I'll actually post that in the, in the video. So you can pause the video and go to this actual page here. Alright, so let's do this. Let's right-click and view page source and everywhere. Well, let's start on line 51 here. And we'll copy star copy and go all the way down to right above the footer. And let's choose copy. And then let us go back to our editor here. And let's, let's highlight all of this, and let's choose Delete. And let's paste it in there and make sure you follow along with me because it's the best way to learn by doing. Learning by doing is, is very essential in PHP development. Alright, so after you paste it in there, lists, choose save. And let's go back to our page and let's refresh. And there it is. I think that's a great look and layout for what we're trying to do. Okay, so before we do anything else layout, let's go to the database and this create a table. Alright, so I want to click on new on the left-hand side. And let's type in at the very top here. Let's talk Bian team. Okay, and let's type in here. Team underscore ID. Here lists Top and team underscore name. Here. Let's talk to him, team underscore title. And right here let's type in teen underscore description. Okay? And let's make sure that we click on odd auto-increment, and we'll leave that as an integers, the type, the name. Let's choose var, char less CH2's. Let's make this 255 total. Let's also add, make that a var char and make it 200. And Item Description. Normally I would make that a text type, but we're gonna just use var char there. And again we'll just do 255, that's File and click on save. And once we are able to see all of our table structure here, what I'd like for you to do is just click on the go. We want to add one more column and let's make it, let's call it date here, because I really like having a date there. So anytime you add. Data in a table, it's gonna give you a date. I think that's really beneficial your ear choice on this, but I like to do it. Alright, so let's choose Save here. Okay, let's go ahead and enter some, some actual data. So I clicked on to team. And then I went to structure here. And let's choose Insert. And less. Less adds some things. You can add, whatever you won't hear. Let's add. Let's go. John Doe. See, okay. This is the CEO. I'm trying to be creative here, but it's just not work in, sorry. Alright. Tom jones, gay, and he is the CDF of the money man. Okay. And let's choose Go on those two. I want to again about six album C structure. And then hit click on browse. Okay, and let's insert some more. Sss. Iq does come more. Ctp, reception, receptionist, maybe. That's spelled correctly. And the answers here and here, this W E S here, call. It looks answers your call. And Mike Jones, I guess you can put anything you want here. I'm just putting something here. Developer. This is our super developer. Okay, let's add two more here. This top of this, Beale, bill Edwards. Okay. Lay his last name a capital E here. Let us say bookkeeper. Okay. And this is the K count into adult and less. Gerry Reid. Gerry's going to be our security. Keeps the bad guys out. Okay? Alright, so now we have, we have our database set up here, and we have six entries in here. So I think we are, we've got a good start. So in the next lecture, well, I'll tell you what before we do that, let's continue on just a little bit longer. I wanted to show you this because only give, give you the opportunity to try this next part yourself. So having said that, what, what I look for is I'll look for duplicates. In that, in those duplicates, what I've realized that I can loop through where the while loop, right? So because we've done that with services and we've done that with products. So we're also gonna do it here. So we want to keep, want to keep this because there's no duplicate. Well, we want to keep all of this because that is essentially this right here. So we want to keep that. Okay? So we just want this area right here. So let's go back to the code. There's no duplicate here. So we want to keep this, want to keep all of this. And we also notice that, well, let me go here. If we go here, you'll notice all these others are highlighted, right? So that tells me there's duplicates here. And then we got when we have one closing div tag here. So that tells me that we can probably get rid of all of this. So let's see. Okay, so we're essentially, all we're gonna do is we're going to loop through, through this part. So I'm going to let you do the next part and then we're gonna go back and go through the next and the next lecture we're gonna go through together and, and make this work. But I want you to, I want to give you the opportunity to try it yourself. As a hint, you can go to Services and see how we've done that. And you can do products and see how we've done that as well. So as always, if you have any questions, let me know, Glad to help. But we'll review this in the next lecture. We'll, we'll solve the puzzle in the next lecture. Okay, see you next lecture. Thank you. 61. Final touches on the about us page: Okay, great. How did you do? I hope you are able to successfully complete that. If not, don't worry, we can do it now together. Alright, so the first thing we wanna do is we want to take this piece here that our team, because we don't want that to loop through. So let's drop this risk down here. So we just want this piece to loot. So all we have to do is go over to services. And let's, let's target now highlighted here all of this. And let's put it right here. Okay, and of course, let's open our PHP tags. And let's close the PHP tag here. Alright. Well that's going to drive me crazy to me. And he took all this here. I'm just gonna try to straighten it up a little bit. Alright, we know that we have an if statement and we got to close it and we got a while loop, we gotta close. So let's do both of those here and here. Okay? And let's change this from services to t. And let's do, put an echo on here because we want to echo the actual love block of code. And let's choose, let it go close this and add this semicolon. And let's refresh. There they are. Now we're looping through every one of them. Now let's go ahead and add the content. So for I didn't mention the actual image. We're going to do the image column as well in just a second. So remember, for this one, if we go back to services, you'll see what we will be done. Let's just take this here and let's put that right here. And I think that was service name. And remember we have to concatenate like so. And here they're okay. That should work. Alright, let's see what happens. I did file say by the way, we got issue, I'll add 35. I guess it's something that didn't like about that. So let's see. I need to change it to team name. That's probably the problem. Let's save it. And there they are. John Doe, Tim Jones, Jessica more might John's bill Edwards and Jerry Reed. Okay, so we've got all those. Let's copy this. And let's add the same thing for title. Title, if you remember. I remember I got that from all of these columns. And we're grabbing the road from each column. So if I go here and also take all of this out in between the paragraph tags. And let's do Control V, Or you can do edit paste. And let's assume description. And now we should see every bit of the actual title and the description for each one. There's the title description. There's the title description, everything. So I would probably I don't know. I think it's not better to actually put a break. Maybe here. Like so. And let's refresh. Yep, that looks much better. Okay. Why? Let's work on the images right quick. I got a few images. I probably won't do them all, but it'll at least give me an idea. You can go on and finish the rest if you'd like. Let's go back to structure. Would clicked on team and we're going to structure here. And let's do add one field after the C, After Description B file. Click on Go. And team image. Okay, and let's just do var bar chart to 55 and save. Ok. So I've already got some images loaded in here that will be included in the in the files for this project. Let's see. So as you can see, I got CEO, CFO, developer, Security anyway. Well, I had some of those. Alright, so let's do this, go to bat, to browse. And let's see, let's start with the CEO. And I'm just going to double-click on this and top band, CEO dot JP, PG. Okay? And will go to here the code. Remember we did the same thing and products. So all we have to do is do this same thing here. So we'll just copy this part here. Like so. And let's go back to about. And it should fit nicely right here. Okay, and we named the meeting. Let me go back and see we name this team image. Okay. I guess I could put Team underscore image. Okay, that's due it let's see let's see if this works. Yeah, actually shows the image. Of course you can modify this. How the circle is, is not quite, not quite right here. You can, you can work all that, all you'd like to get it right, get it better. And so I'll go to C, F dot JPEG. Okay, and let's reload, save different size images, but you can kind of see how we have it here. I'll add a couple more. You can add a style to make sure all these are the same and things like that. But my goal is just to show you that this will work from the actual database. And so that one is RAC dot JPEG. Alright, let's try this one. And we see dot JPEG, JPEG. Okay, I think this one was called, Think I named at developer dot. Say what did I name it? Developer dot JPEG? Yep. Okay. C to make the tea and ANOVA named this one security JPEG. And that should be all levels except for one. There we go. And actually kind of looks kinda cool this way anyway, instead of the same size. And let me let me add this last one. Think I named it bookkeeper. Yep. Okay. Eeprom.h, JPEG. Okay. Alright. So here There's a bookkeeper. So, so anyway, was suddenly, now we have a very nice About Us page. I hope you are able to successfully go through this either by yourself or with me. So I'm always glad to help you. Let me know if I could contact me, if I can help you in any way. But I think I think we're good to go on this. And next, we'll work on the final peace, which will be our Contact Us page. And on the contact us page, we will actually submit data to the database. So it's gonna be a little different, but it's going to be cooled. Okay, see you in the next lecture. Thank you. 62. Create the contact page with form (Part 1): All right. So looks like we are going to work on the contact page because how can you have a business website without some way to, for your visitors to contact you. So we're going to work on building a contact page and submitting the data from the form to the database. So this is this is our starter template here for the contact. So this is the page we're going to work on, but I want to backtrack just a second and take care of a couple a couple of things. And the first thing is in your, if you'll open up your menu, WHO make sure you take out? If I think of added before I added, include the DB connect, just like in the header. Just like this, if you have one in menu at the top, go ahead and remove that. The second thing is if you open up your footer dot PHP file and it makes sure the only thing you have in here, because I think I added this, Liam and all those. There's a couple of different ones in there. Popper I think Popper JS, I think I had add those in there. If those are in there, just remove that. Only thing we need is just this. Okay? Now, we'll move on and let's start working on the contact page. Alright, so the first thing we want to do, obviously is we want to remove all of this. And then let's create a container. Okay? This is part of the Bootstrap stuff. All right, and let's do a closing D of here. And let's, let's put a comment so we know where the end of the container is. And this is very helpful by the way. And this is kinda like the wrapper around everything. Okay? The next thing is let's do a tab. And let's do, I want to add a response message? When someone fills out the full lot? This is the area where the response is going to be the C tip class. I could spell it correctly here. Div class equals S2, response dash MSG. Okay? And we can also go ahead and just close that day of here because we're going to use JavaScript to actually input value within this class. So, so, and we're also going to use Ajax to, I think you really like that as something new. Don't, don't worry. I'll I'll talk talk you through it and you understand it. Okay, so the next thing is, let's do a tab and let's do deal class equals row. Okay? And let's close that. Let's go down to here. Unless tab over a couple times. And let's well, let's go back to here. And close the deal. And let's make a comment on that. And row. Okay? Alright. Next, we'll go ahead and let's open up a div class equals, and let's call this. This is going to be for your bootstrap grid. So you should see, I will post the link to bootstrap grid. And if you wanna take a look at it, and let's go ahead and make this COOH, L dash amd, this is column medium. And let's do eight here. Alright? And of course, we want to close that. Forgot to notice how the color is different here. I can see that made a mistake here. So let's do this. Alright, and for this one, less tab over T, IV, V, VI. See I want to close the deal and they get it right here. Okay? Alright, and let's just copy this. Okay? So and column. Okay? So there we go. So now we can move this down. And let's go ahead and start adding the fields. So well, run up under this. Let me go ahead and add an H1 tag. And this is going to be our title at the top. That's the contact us today or something. Okay. It was closed H2. And let's go here. And now let's go ahead and open up our film. If you know anything about HTML forms, this should look very familiar. Form name equals, and let's do contact. Form. Action equals. This. Put nothing in there, just a couple double-quotes. And I'll know blot does that sometime. And let me do this as probably why. Okay, nothing in there because the form is going to submit to itself. Method equals post. Now, the two most prevalent types of methods is posting get that when you're dealing with forms that you're submitting, its best stopped to always use post. Okay, d is equal to contact. Dash here. Okay? And let's see, let's do this. Open up a deal. Class equals four dash. Okay, so, alright, so this is the h individual section, this is part of Bootstrap stuff. Alright, so the next thing is let's do label four equals name. And that's dou capital E. K, c includes humans unless sooo, close label. Okay? All right, and let's do input. This is the actual field here. Type is going to be text, is text. Okay? Let's say class equals form control. And if you make sure your top along with me. So, so it'll help you learn better. C, O N T, K. And let's see, let's give it a name equals name. And then Placeholder. Placeholder is what's going to be inside the actual field by default. Equals name. And we're going to add HTML5. Element called require are required or EQ EUR ED. Okay? And so that will, that will actually help us with validation, front end validation to and let's do deal. Okay, so what we've got here is we successfully added our first, first field. And this wants to act out, okay, all right, so let's save this and let's reload. And let's see what we got. We should just have one that says name one field. And we do there it is. Okay, so now all we have to do this quickly, copy this. So we should be able to do this. We'll copy all of this. And we got one for name, we've got one for email address, we've got one for phone, and one for comments, which we will change that from the input, input type of text. That is going to be a text area. But we'll fix that. All right, so let's do this. The first one is email us. Email address, okay. And let's do this name, this email. And this two email. Okay, make sure that's lowercase capital E. This is what's going to be shown. This one is going to be phone and sname than this, but this foam as well. Okay. This one is going to be fun. This one is going to be phone. And listen. Take whom lists. Let's do this. I'll just remove all this for now. Okay, let's do this. Let's name this comments. And let's make this comments. Okay, and let's open up our textarea tag. Okay, and let's give it a name. Name, his comments, like that. And let's give it a class equal to form control. Okay? And then we'll do rows equals three. And let's do something like Kohl's equals 28. And let's do a placeholder equals comments. And let's close our text area. Okay, like so. Now when we reload, we should have everything but our submit button. And we do. Okay, so I'm going to stop the lecture for route here. And then in our next lecture we're going to add our submit button and work on adding our database table and columns. Okay, we'll see you next lecture. Thank you. 63. Create the contact page with form (Part 2): Okay, let's go ahead and add the submit button. Ok. So we opened it up with button. And let's do type equals submit. Let's see, class equals. This is part of bootstrap as well. Btn, BT in dash, I think it's a primary. Ok. And that's basically to make the button. I believe it's going to be blue. Name equals submit. Unless to value equals summit here. And i d equals submit underscore form. Ok, and let's close it here, and let's type in submits. Let me take this space out. Ok. And let's close the button. Like so. Alright, and let's close our form. So our form, like I said, needs to be closed as well. Okay. And weird to be in the form they are. So I'm just going to add that removes some of these spaces, is clean them up a little bit. Okay? Alright, so now let's save that. Or you could do, I did controlling es as always do. But you can do File Save and let's refresh it. And now we should see our button. And there's a button so we can submit. But of course nothing's going to happen yet because now we need to add the logic for that. But before we do that, let's go in and let's create our structure for our table for a contact form. Alright, so I've already imported in hand, but I'm gonna import it again to kinda show you the see, if I click on framework because I've got a file that I'm including this called, let me go to it's called contact underscore form dot SQL so you can import it in like we did before. But I'm gonna do it again. Yes, see, let me drop this table. Okay, we'll choose draw. K takes a second. All right, so it's gone. So now we can use that file that I was referring to. Us, choose clicked on import and then bridles, and then on choose Contact underscore form SQL. And let's click on Go. And that's going to create the structure of the columns and the actual table. So we'll give it just a second. Okay? Now, if we click on content for Here's our structure. And if you'd like to go in and do it manually, as I said before, you can, I've got ID, integer ten, name, varchar 200, email, varchar 200, phone, Var2 are a 100 comments, texts, and date is the timestamp. Always like to add that date. So you can determine when submission has been entered. And so it makes it really easy. I do that anyway, makes sure that you check the little box AI for auto increment for the ID. And you should be a business. Okay, let's continue there. So we gotta db setup our table, set up ready to go. Alright, so let's go back to contact. Alright, so I'm going to just paste in this code to kinda speed, speed up the process a little bit. But I want to explain it to you. Alright? So let's go here below the ending container. And I'm pasting this, and of course I'm going to include this code here. But this, this is a part, I'm gonna explain this to you. This is part of JavaScript, and we're also going to be using ajax. And basically what Ajax is gonna do normally when you have a form like this and you hit Submit, it's going to go to another page and it's gonna say, you know, thank you for your submission or whatever. So what we're gonna do is we're gonna remain on the same page, so we never leave contact dot PHP, it's always going to remain the same. And we're just going to have a message. It's gonna pop up here for a specific amount of time. That's going to say, you know, whatever we want it to say, you know, thank you for your submission or whatever. So that's kinda how that's gonna work. So basically we're opening up our script tag here. We're, we're loading JavaScript here. And I want to, I want to tell you about one more thing here. The pound or the hash symbol versus the period. Do you know the difference? Okay. The hash symbol represents Addie, okay? The period or the dot, it represents class files. So let's, let's look at Hmm. Let's look at this one, for example, response message class. So notice this got the period response message. Okay? So that's telling it to basically look for this and then inject some data into it. That's what that's all about. And that's really important concept in JavaScript is for IDs and classes. So you can reference a class or an ID, like I said. So this one's basically say look for the ad the of contact dashed form. So we see that, we see that. Actually here, contact dash form. So we see the ID contact form. That's what that means. Anyway. I just wanted to kinda clarify that. This is to prevent it from double submitting when someone submits a form. So basically it says, okay, whenever we click on submit, which that ID that I showed you up here is also used here. And think, I'm sorry, no, no, that's not right. It's it's actually here. It's this form. Okay? And and so basically once that form submit button is clicked, then it's gonna run all this code here. So what we're doing here is we're looking for the same ID, the form, we're looking at that form and we're looking at name. And instead of your name, this should actually be named. This should be name as well. And I go and change that. This is email. This is email. Okay. And and so we're basically just checking to see to make sure that if it's, if it's empty, we want to put a red line around it, but the required this does the same thing. I believe. That required adds the red line around it anyway. So we're basically doing a check here. And it's going to load a loading image. And I've actually included that here. But you can download your own loading dock GIF, you'll see it right here. And let's say we're also going to need to add some CSS for this, but we will get that in just a second. All right, so we're creating a JavaScript variable here called Send data Emory. We are serializing all the data here. And we're going to pass it via the post variable to a file called get response dot PHP, which were not created in the next lecture. This is the data here, and this is a return data. So we're bicycling and return it and put it here in the and the response message. That's why I've created this. So it will inject it into that. Alright, so and basically come down here, we're just doing a blur. We're doing assignment a variable called Check value, we're checking. And then assigning this, this the CSS element of border bucket inline style is what it's doing with this color. Ok, so we have that. Again. If we hits, I did file AES, I'm sorry, control S to save. You can do File Save. And we go here, hit refresh a One more thing I meant to tell you. Up here. Something I noticed earlier changed this from input type text to input type of email. I forgot to do that earlier. Okay, lets save it. Control S. And let's go here. And now when we submit, it's going to say please fill out this field for HIT contact and we hit some yet you gotta knows, all three lines highlight because they are required. All three fields rather highlight because they required. Okay, so the very last thing I'm gonna do is I'm going to actually add n, The style because we have a certain style. So I'm just going to copy what I have here and I'll paste it in the starter template or may already have it in here. Yeah, do. Alright, so here's the style. If you wanna go ahead and type that in your starter dash, template dot CSS or your own custom. If you created a custom name for that, whatever. Just make sure you type this out, just pause the video and type all that. And next, we will come back and we will work on the new file called get underscore response dot PHP. So if you wanna go ahead and jump ahead going create a file called get underscore response dot PHP. Ok, we'll see you in the next lecture. Thank you. 64. Create the contact page with form (Part 3): Ok, let's work on the next part, which is going to be the get response dot PHP. So of course, maybe you created that file already if you didn't, that's okay, we'll create it now. Let's right-click and choose New File. And the statement get underscore response dot PHP. Okay. Make sure I have that spell correctly. Yep. Yep. Okay. All right. So let's go here. And to save time, I'm gonna go ahead and just paste the code in here. And we'll just review it. So let's paste it here. Okay? Alright, so let me, let me explain what's going on in the first thing we need to do is we need to require, require once the ADB Connect. So we're going to have to connect to the database obviously. Alright, so the next part is we want to, we're checking here to make sure that a post variable called name and post the variable called name is not empty. So we wanna make sure it's set. And we want to make sure it's not empty. So we're going to do the same thing with the email too, to make sure that there is something being passed in a post variable called email and that it's not empty. Next thing is, we want to grab that post variable. Here. We run a run it through this real escape string, which basically sanitizes it to prevent SQL injections. So this is a very important piece. This is our connection object from from the ADB Connect. I'll show you that. Let us go here. It's going to interconnect. And you'll notice it's right here. This is our connection. Okay? So let's go back to get response. Come on. Take a second load, okay. All right. And then we're basically assigning all of this to name, email, phone, and comments. Next comes our query. We gotta SQL here, query insert into contact form. This matches our columns that we created in the database name, email, phone, comments, and these are the values. This is the variable for name here. This is the variable for email. Here. This is the variable for phone here, and this is the variable for comments here. And then we're doing a, basically a check to check if something happen, you know, is gonna give us an error. Hey, I wasn't able to, for whatever reason, connect to that database or was able to run this query else. Thank you. We will contact you sin. Now here's the interesting part. This is the return data that we're gonna get back here. Remember I was talking about we're going to inject into the response, will want to inject a message into here. That's why I created it, the response to estimate dash message. So down here, remember, remember this piece. This is what's grabbing the data that comes back from the send data here, which will make an ajax request. Alright, so I'm gonna go back to get response. And if you want to include this code obviously, but you can pause it right here and you can top it out, which would be great practice. You're more than welcome to go ahead and do that. Otherwise, we'll keep moving forward. So I'm gonna save it. So what should happen now? Oh, there is one other piece. I'd like for you to go to. Here. Type in this URL. I'm on a, on a, post it here. And we want to make sure we looked for an Ajax library. So even though we've got jQuery, that's fine, but we still need the Ajax library forward. So we're going to right-click and choose copy. And we're gonna go back to the header. And let's go here. And I've already added it here, but, but you would add all of these. So if you want to pause the video again and top all this in Baal means or you can go to the page and hollow out between the double-quotes and pasted in here, however you want to do it, and that's fine. But I've got it added here. So let's go think everything. Let me make sure I've got everything saved here. So there's contact, save under control. As always do Control S here, Save. All right, let's see what happens this, make sure everything works as it should. So we go here. I'm going to refresh this page. Okay? And I'm also going to check the content form and we'll click on that. And let's make sure we don't have anything in here which we shouldn't. But I'd just like to show you that we don't have anything. So that's taken a second. Okay. Notice we don't have any, any entries in here, so let's try this. Let's try Bob jones. Okay. Bob at Jones.com. Okay. Let's give them a phone number. Five, that is 1212. And this is my comment. Okay. And what should happen? We hit Submit. Oh, let me, let me do this. Are you familiar with the Web Developer Tools that comes with Firefox or Chrome? If you're not, it's, it's, it's good tool. I use it all the time. So what you can do is if you have your browser open press F2. And what should happen is you should see something like this. And what we can do is we can actually see the requests being made, which is very helpful and we can see what's being passed. And that's what's the benefit of this is before this, CSS was tough anytime you you deal with APIs and was very tough. So this here is a lifesaver. Okay, so remember that f 12 on your keyboard. Ok. So what we'll do is when we hit Submit will watch. Let's see what happens. You've seen yet it's passing to get response is making a post request, but we did get a 404. And I'm wonder why. Let's see, we should have got a 200. There's the parameters but it says four or four. Let me make sure. Let me see. Okay. Alright, so we've got the 44. And really doesn't tell us as to why. Here. There's console is network, we get a 404. Let's see. Let's see, we've got get response here. Here. Here, see all this looks files. And wonder why we didn't know givers. Ha OK. I think I know what's happening is at 44 represents it's not found. So I probably made a mistake with the actual name. So let me go back to here. Let me check. Check here. Yep. I'd thought I'd thought I spelled it correctly and I didn't. So let's see. Let's go back here. Re S P O N S E should be right. R E P R E S POE NSC. Yeah, that looks right. Oh, okay. My mistake. I'm sorry. So that's how, you know, things happen and that's when that was good that that happened because we were able to see that in this F 12 here, the web tools when we press F 12, because we saw that the status, we should have got a 200, which is a success server or status, but we've got a 404. So with that being said, let's go back. We'll save it again. I did control AS, But let's click on contact. And let's try this again. Give me a second here. Let reload. See notice all these, say 200. So it was, it got all of these pieces and parts successfully. Alright, so let's go here. Let's toughen Bob Jones again. Okay? And for the heck out of list, check the validation. See it found out, alright, if decided that hey, there is nothing in email, not that involve alright, email address. I'm at Jones.com. There in here. Here is my Tom yet. Okay. And let's choose hit a little trash cans. We kind of clear this and let's see if we get a 200. All right. We got a 200. And you didn't see it at the top because I was looking at this. But I also want to show you, I will show you the message of second. When you click on this, if you look here, you'll see parameters. This is everything that's being passed in the fall. See all that. That's what we're that's tells us a lot. And this the response is what's being sent back. This is what we were talking about with this I'm sorry, with this here. Ok. So we're basically grabbing that's that data that's coming back from the success message here. And we're inputting in response. So let's check that now. So it should appear at the top here. Alright, so let's do this is click on Contact to kinda just reset it here I'm click on trash can. Lets do. Steve smith, OK. And TED at Steve.com. All right. And let's just get whatever phone number and whatever text we want to put it in there. Okay? And then exit out of this. So when we hit Submit, we should see the return message. Submit. Ha, didn't see the return message. So we'll, okay, we'll continue to work on that next in the next lecture. Alright, see you in the next lecture. Thanks. 65. Finalizing the contact page: Alright, in our last lecture, we were experiencing an issue to where the success, successful submission message was not displaying across the top. So let's work on that now. So if we, if we add an ACE is just just testing email, address, phone, You know, I misspelled that. Let me fix that right. Quake1. Let's see. Let's see that should be here. Ph O N E. I go back and refresh that. Okay. We have name, email address, phone comments. So it hit submit. And notice we didn't get the success message at the top. So let's fix that. So to troubleshoot that. And this is a great time to troubleshoot because we're seeing a problem. So let's go here. And I'm going to type in alert. And we know this is the success message here. And we know it's, the data is what's coming back from the get response. So I wanna do is add the variable data in here. And let's see. And that should do it here. This add a, put a semi colon on the end. Save. And let me go back to here. And I'm going to do control F5 to make sure that it's got all the changes. And I'm gonna click on that, it load here and click on contact just to be sure. Ok. And now what should happen is let's look at the response and we'll see what comes up. So if a tub ingest testing, for example, here again, and we hit Submit, we see the response. Well, we should've seen that, well, there's a response there. And the response coming back is this. And we see it's here. So that's telling me that something is going on with this. So we got response message here. Oh, and by the way, you could have used console.log here. If you know JavaScript, you can use that to, I just use the alert. So let me fix this. So let's tell me it is successfully getting here. And so I need to check this response message, see what's going on here. There's the problem that should be underscore response message. Okay, let's try another test. Let me go back and make sure I have that saved. I did control s. You can do File Save. Obviously. Let's go back to here. I'm gonna do Control F5 to clear my cache. And let's just do Bob Smith. Bob at Smith.com, phone numbers, whatever. And let's do this. Let's hit submit. There it is. Thank you. We'll contact you soon. It'll disappear. And let's go back to the database to make sure it successfully submitted. And that was Bob Smith on the last successful wine when the resubmitted. Okay. There it is. Said how narrative database Bob Smith. Bob at Smith.com, number and comments and the date, the time stamp. So I think we successfully, or I know we successfully created in our form. We linked it to the get response. We was able to successfully use ajax, which is very cool. You learn something new here. And that's an ajax request. And if you have any questions on this by all means, let me know. And the final thing I want to add is we can't test sending out because oftentimes when you have a contact form and if all your information goes into, your data, goes into the database, like we just saw, that. You also want to get an email saying, hey, somebody submitted the contact form, you know, whatever you want it to say that comes to you or or maybe something to go to them. But, but anyway, so let's do this. If you'll notice at the top here. No, I don't have it. Probably need to add it. Get response. Let's see. Do I say, yeah, I have it here. Alright, so all you have to do is uncomment this and will create, right-click and choose New File. And let's name this contact underscore mail dot PHP. And I'll paste the code in here. Give me a second. And this is what it looks like. As soon as it pace here. Okay? So we still have to connect to the DB here, right? That's not it. I'm sorry. Okay, we'll go back to here. Okay. This is what it looks like. Alright, so just the simple mail script. Who is, who's it going to? The from? Name and email and echo contact male. See it. And or it's going to give you an error problem in sending mail. So I'm going to constantly be updating the course. So I'll add this to the files for the whole framework so you can see it. And if you upload it to a host, you can test this out for yourself. But just change this to your email address. And then what's supposed to happen is once this, once the form is submitted, it does ajax call to this here. And it's actually going to being that we are requiring the contact male. It's going to require this and it's also going to see the post variables, the post name or post email here. And then it's going to check to see if, if all that the comments and posts and all that are there and it should send Shin the actual syntax will email out. So I don't have a way to test this. So we will, I'll I'll just include it here and we won't go any further on it. But anyway, you can do some more research on that and you can build your own. Or I may add it on to the course later as an addition because this is ever-growing course. So having said that, that is the end of our contact, building our contact page and form. All right, I'll see you in the next lecture. Thank you. 66. Conclusion: Wow, that was a lot of material that we covered in this course. I hope that you are able to get a good grasp on PHP development. And I want to thank you for supporting me and taken my course and making it this far. Because that shows that you have determination and dedication to pursue your PHP career. And so I wish you the best of luck in the future. And again, I wanna thank you for purchase of my course and go on through everything. And, and as always, if I can help you in any way, please please reach out to me, let it let me know and I'll be glad to help any Rackham again. Thank you very much and good luck in your future endeavors.