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

1.use phpmyadmin to create a database for the three types of coffee and their re

ID: 3592521 • Letter: 1

Question

1.use phpmyadmin to create a database for the three types of coffee and their respective prices

2.on clicking the checkbox on the website, user can key in new sales price for a cup of coffee using SQL

3.updated sales price automatically retrieved and displayed onto the same webpage for user confirmation

Webpage code

HTML code:

<!DOCTYPE html>

<html>

<head>

<title>JavaJam Coffee House Menu</title>

<link rel="stylesheet" href="javajam.css">

</head>

<body>

<div id="wrapper">

<div id="header" align="center"><img src="title.gif" align="center"

height="auto" width="auto" alt="JavaJam Coffee House" /></div>

<div id="leftcolumn">

<nav>

<ul>

<b><li><a href="index.html">Home</a></li> &nbsp;

<li><a href="menu.html">Menu</a></li>&nbsp;

<li><a href="music.html">Music</a></li>&nbsp;

<li><a href="jobs.html">Jobs</a></li></b>

</ul>

</nav>

</div>

<main>

<h2>Coffee at JavaJam</h2>

<table>

<tr>

<th>Just Java</th>

<td>Regular house blend, decaffeninated coffee, or flavor of the day.</br>Endless Cup $2.00</td>

</tr>

<tr>

<th>Cafe au Lait</th>

<td>House blended coffee infused into a smooth, steamed milk.</br>Single $2.00 Double $3.00</td>

</tr>

<tr>

<th>Iced Cappuccino</th>

<td>Sweetened espresso blended with icy-cold milk and served in a chilled glass.</br>Single $4.00 Double $5.75</td>

</tr>

</table>

</main>

</div>

</body>

</html>

Explanation / Answer

The below code is used to create a database connection using phpmyadmin or localhost.
<?php

function OpenCon()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "1234";
$db = "coffee_details";


$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s ". $conn -> error);


return $conn;
}

function CloseCon($conn)
{
$conn -> close();
}
  
?>

The below code is to create a text box which is used to update the coffee price when you check the check box. This is a single code for just java coffee and you can update with the more number of coffees.

<script type="text/javascript">

    function EnableDisableTextBox(justjava) {

        var txtjustjava = document.getElementById("txtjustjava");

        txtjustjava.disabled = justjava.checked ? false : true;

        if (!txtjustjava.disabled) {

            txtjustjava.focus();

        }

    }

</script>

<label for="justjava">

    <input type="checkbox" id="justjava" />

    Update just java price

</label>

<br />

Just Java Price:

<input type="text" id="justjava" disabled="disabled" />

The below code is used to create a command to the database for updating the information that is read fron the input text box.

con = new MySql.Data.MySqlClient.MySqlConnection(connstring);
        con.Open();
        cmd = new MySql.Data.MySqlClient.MySqlCommand("UPDATE coffee_detail SET just_java_price='" + justjava.Text);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote