Question: page1.php Connecting MySQLi Server /// retrieve.php Create a script (retrieve.php) that performs the following operations: - retrieving the data of all instructors from the database.

page1.php

Connecting MySQLi Server

//-------connect to MySQL database system------------------------------------

$dbname="zed2";

$tbname= "instructorInfo";

$dbhost = 'localhost:3306';

$dbuser = 'root';

$dbpass = '';

$conn = mysqli_connect($dbhost, $dbuser, $dbpass);

if(! $conn ){

print "Could not connect: " . mysqli_error();

}

print "Connected successfully";

//-------choose a database to use------------------------------------

mysqli_select_db($conn, $dbname);

//-------insert two records into a table------------------------------------

$sql = "INSERT INTO $tbname "."(I_ID,name, phone, department, college )".

"VALUES(1000,\"Tammy Connally\", \"3601234567\", \"cs\", \"science\")";

$retval = mysqli_query($conn, $sql);

if ($retval)

{

print "data is inserted successfully ";

}

else

{

print "Error inserting data to a table: " . mysqli_error($conn);

}

$sql = "INSERT INTO $tbname "."(I_ID,name, phone, department, college )".

"VALUES(1001,\"Long Grisham\", \"36023456789\", \"English\", \"arts\")";

$retval = mysqli_query($conn, $sql);

if ($retval)

{

print "data is inserted successfully ";

}

else

{

print "Error inserting data to a table: " . mysqli_error($conn);

}

$sql = "INSERT INTO $tbname "."(I_ID,name, phone, department, college )".

"VALUES(1002,\"Nakisha Voth\", \"3607654321\", \"cs\", \"science\")";

$retval = mysqli_query($conn, $sql);

if ($retval)

{

print "data is inserted successfully ";

}

else

{

print "Error inserting data to a table: " . mysqli_error($conn);

}

$sql = "INSERT INTO $tbname "."(I_ID,name, phone, department, college )".

"VALUES(1003,\"Barton Bembry\", \"3601230000\", \"math\", \"science\")";

$retval = mysqli_query($conn, $sql);

if ($retval)

{

print "data is inserted successfully ";

}

else

{

print "Error inserting data to a table: " . mysqli_error($conn);

}

mysqli_close($conn);

?>

/// retrieve.php

Create a script (retrieve.php) that performs the following operations:

- retrieving the data of all instructors from the database.

- using a for loop to print the data of each instructor.

- when printing the major of each instructor:

- if the retrieved major of an instructor is cs, print the major as computer science;

- if the retrieved major is math, print the major as mathematics;

- if the retrieved major is phy, print the major as physics;

- otherwise, directly print the retrieved major.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!