Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have two tables in my database. 1- Student (`sid`, `last`, `first`, `birthdate`, `gpa`, `advisor`) 2- Advisor ((`advisor_id`, `advisor_first`, `advisor_last`, `office`) I need to :

I have two tables in my database.

1- Student (`sid`, `last`, `first`, `birthdate`, `gpa`, `advisor`)

2- Advisor ((`advisor_id`, `advisor_first`, `advisor_last`, `office`)

I need to :

Create a PHP file named db.php. Add code to db.php that connects to your database using a MySQL connection. Do not put any HTML in this PHP file, just PHP.

Create a second PHP file named Work3.php. Use include or require to bring in db.php and create the connection.

Add 5 queries to the Work3.php file. The queries should display the following. The data comes from the tables you created:

  1. sid, first, last, and birthdate columns for all students
  2. all data for the student whose sid is 818347712
  3. first, last, advisor for students whose advisor is 1 or 2. Only the advisor's number is required. So, you do not need the advisor table. You can add the advisor's name if you want to create an SQL join.
  4. first, last, birthdate for students whose birthdate is MORE recent than January 1, 1960 (hint: Do not include January 1, 1960) Order the result by birthdate, last, first
  5. first, last, gpa for students whose gpa is between 3.0 and 4.0 Use the SQL BETWEEN operator. Order the result by gpa

In your PHP file display each query and result set as follows:

  • Heading row (e.g. use an

    element) with the SQL that was executed.

  • The result rows one row per line
  • Some white space (blank lines) then the next heading row.

Test your code. Compare the results with the phpMyAdmin results.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions