Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

__ Write down the missing code according to the comments included in the code ro

ID: 3902966 • Letter: #

Question

__ Write down the missing code according to the comments included in the code

roominfo.php

<?php

print"

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Product Cost Calculator</title>

</head>

<body>

<div><p>Room Information</p>";

print"

<table border="1" width="600" height="200">

<tr><td>Room_No</td><td>Bed_type</td><td>Price</td><td>Book_it</td></tr>

<tr><td>1</td><td>1 king bed</td><td>$89</td><td><a href="bookroom.php?room_no=1&amp;price=89&amp;how_long=3">Book</a></td></tr>

<tr><td>2</td><td>1 qeen bed</td><td>$60</td><td><a href="bookroom.php?room_no=2&amp;price=60&amp;how_long=4">Book</a></td></tr>

<tr><td>3</td><td>2 king beds</td><td>$170</td><td><a href="bookroom.php?room_no=3&amp;price=170&amp;how_long=1">Book</a></td></tr>

<tr><td>4</td><td>2 qeen beds</td><td>$110</td><td><a href="bookroom.php?room_no=4&amp;price=110&amp;how_long=2">Book</a></td></tr>

</table>";

print"

</div>

</body>

</html>";

?>

bookroom.php

<?php

funA($_GET["room_no"], $_GET["price"], $_GET["how_long"]);

function funA($roomno, $priceinfo, $howlong)

{

print"<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Greetings!</title>

</head>

<body>";

$room_no=$roomno;

$price = $priceinfo;

$how_long=$howlong;

$total=$price*$how_long;

$disaccount=0;

if($total>260){$disaccount=30;}

elseif(($total<=260)&&($total>240)){$disaccount=25;}

elseif(($total<=240)&&($total>220)){$disaccount=20;}

elseif(($total<=220)&&($total>200)){$disaccount=15;}

elseif(($total<=200)&&($total>180)){$disaccount=10;}

else { $disaccount=0; }

$totalbefore=$price*$how_long;

$total = $price*$how_long*(1-($disaccount/100));

print"<ul>

<li>You will receive $disaccount% discount. </li>

<li>Your total payment before discount is $totalbefore.</li>

<li>Your total payment is $total.</li>

</ul>";

print"

</body>

</html>";

funB($room_no,$how_long,$price,$totalbefore, $disaccount);

}

function funB($room_no,$how_long,$price,$totalbefore, $disaccount)

{

/*

this function will perform the following operations:

(1)create a database having one table. The name and data type of each column of this table is below:

- room_no INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,

- hong_long int,

- price double,

- beforecost double,

- disacoount double

(2) insert the data into the table, including room number, how many days to stay, the price, the cost before the discount is applied, the discount.

*/

}

?>

Explanation / Answer

If you have any doubts, please give me comment..

please provide credentials

<?php

function funB($room_no,$how_long,$price,$totalbefore, $disaccount)

{

$servername = "localhost";

$username = "root";

$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 to create table

$sql = "CREATE TABLE IF NOT EXISTS BookRooms (room_no INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, how_long INT, price DOUBLE, beforecost DOUBLE,discount DOUBLE)";

if ($conn->query($sql) === TRUE) {

$sql = "INSERT INTO BookRooms VALUES ('".$room_no."', '".$how_long."', '".$price."', '".$totalbefore."', '".$disaccount."')";

if ($conn->query($sql) === TRUE) {

echo "Successfully Room booked";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

}

} else {

echo "Error creating table: " . $conn->error;

}

$conn->close();

}

?>