R: Reading Data
Reading data is essentially just pulling data from the database. We did this before in Lesson 8: Using Database -> Getting Data From Database so this will mostly be a revisit. However we are going to talk here about creating a webpage that serves as the main point for managing all the data operations –…
Read MoreC: Creating or Adding Data
You know how to make forms and you know how to insert data using SQL – let’s put the two together! Let’s insert a member into the Members database structure shown below. First, create your form as you normally would in HTML. The only difference is we need to add a link to the PHP…
Read MoreMore on Getting Data From Database
Now that you know how to do a basic connection to the database and retrieve data, let’s revisit how you would do more complex SQL queries with WHERE clauses, ORDER BY, GROUP BY, and even joining tables. Guess what – it is easy – you already learned it! All you have to do is replace…
Read MoreUpdating, Inserting and Deleting Data with PHP
You know how to get data from your database…but one of the great powers of PHP is letting the user update, add and remove information. First, let’s go over the basic syntax for doing this in SQL. If you need to review the SQL – here’s the section on how to add, update or delete…
Read MoreGetting Data From Database
1. Connect Now that we know how to connect to a database, we can get data out of it. The first step is from the lesson before….connect to the database. <?php //set up connection variables $servername = ‘localhost’; $username = ‘mscoding_members’; $pwd = ‘nottelling’; $dbname = ‘mscoding_members’; //connect! $conn= new mysqli($servername,$username, $pwd, $dbname); //Check to…
Read MoreHow to Connect to Database
Not enough permissions to view this content.
Read MoreHomework: Loops in PHP
Woohoo! Let’s have fun. Create a new file called loops.php. Do this! For loops Print out 1+2+3+4+5+6+7+8+9 on one line. There will be no “+” at beginning or end. Print out the sum of that loop after. Copy over our animal array to here – save you some time. Loop through the array and print…
Read MoreHomework: Play with Arrays
We are going to play with arrays a little so make a new file called arrays.php and let’s have some fun. Create an array called $animals and put 4 of your favorite or not so favorite animals in there. Create an echo statement that prints out a sentence like this: “My favorite animal is ____.…
Read Morefor & foreach Loops
There are several kinds of loops – we will learn about for loops first. for Loops A for loop is a loop that will repeat a set number of times. These have very similar syntax to JavaScript – and similar functionality to Python. Depending on where you are coming from. Here is the basic structure:…
Read MoreHomework: Where Variations
Not enough permissions to view this content.
Read More