Question

This assignment will assess the competency 3. Construct advanced SQL queries. Directions: Using your account at...

This assignment will assess the competency 3. Construct advanced SQL queries.

Directions: Using your account at 000WebHost and PHPMyAdmin, create a PHP pages that

Display data from your database.

Add records to your database.

Include the URLs for your instructor.

Install PHPMyEdit from PHPMyEdit.org.

Create a data view using the software and your dataset.

.

Homework Answers

Answer #1

Solution:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id, firstname, lastname FROM MyGuests";


$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>

//using the sample script above you should be able to select and view data from database.

//the following script should help you know how you can add records into a database table

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', '[email protected]')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Refer to Critical Thinking Assignment – Option 2 in Module 2. Your tasks begin by generating...
Refer to Critical Thinking Assignment – Option 2 in Module 2. Your tasks begin by generating and executing the SQL statements to create the Sales and Purchased Items tables. Next, you will develop and execute the SQL statements to populate the 2 database tables from the data in their respective tables in the Critical Thinking Assignment. Finally, you will write and execute queries to display all attributes (columns) and tuples (rows) in the 2 database tables. Important reminder, refer to...
Assignment 7 This is a two-part assignment. Students will create and submit 3 scripts. Here are...
Assignment 7 This is a two-part assignment. Students will create and submit 3 scripts. Here are the instructions: Before You need to Import the books_sc database via phpMyAdmin Script 1 Create a php file to connect to the books_sc database. You can name this file connect.php. This separate file will be ‘included’ in the other scripts, script 2 and script 2 Script 2 (25 points – to receive these points, you need to have the connect.php file created and submitted)...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make the files to create and populate the Company database available on Isadore shortly): List the last name and address of managers who have a dependent with the same first name as themselves. Retrieve the names of all employees who are directly supervised by ‘Franklin Wong’. Retrieve the names of employees in the Research department who work more than 20 hours per week on the...
Q1) Connect to HR database and write the queries to answer the following questions. Provide your...
Q1) Connect to HR database and write the queries to answer the following questions. Provide your queries text and result in a .txt file: a) How many employees you can find in the Employees table b) How many departments are there in this database c) How many employees work for sales department d) What is the average salary of department 50 e) Copy Countries table from HR database into Section 24 using Select Into clause. f) Write a query to...
A Guide to SQL Questions 1. How do you create a table using SQL? 2. How...
A Guide to SQL Questions 1. How do you create a table using SQL? 2. How do you delete a table using SQL? 3. What are the common data types used to define columns using SQL? 4. Identify the best data type to use to store the following data in Oracle, in SQL Server, and in Access:    a. The month, day, and year that an employee was hired    b. An employee’s Social Security number    c. The department...
Using JAVA Resource: "Starter Code to Access Tables via JDBC" text file ******** PASTED BELOW ****************...
Using JAVA Resource: "Starter Code to Access Tables via JDBC" text file ******** PASTED BELOW **************** For this assignment, you will create Java™ code that accesses a relational database, requests data, and then analyzes and displays a portion of that data. Imagine that a MySQL relational database schema named COMPANY_DB containing two tables, employee_table and payroll_table, such that the records in each of the tables is as follows: ·        employee_table: Emp id FName   LNname Addr City State Zip 100 Jack...
Using mySQL, tables at the end... This assignment uses the tables from the vets database. The...
Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goal of the assignment is to get you to think about joins- inner join and outer joins.  If you do a join, where you have the names of two or more tables in the From clause, then you must use the condition join syntax or the column name join. Take care that you do not accidentally do a Cartesian product. If your result set contains...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT