Wa0013 - 1
Wa0013 - 1
Wa0013 - 1
Source Code
mysql> -- Retrieve employees with a salary above a certain threshold (e.g., 42000)
mysql> SELECT * FROM tblEmployee WHERE Salary >= 42000;
+ + + + -+ +
| EmpID | EmpName | Designation | Department | Salary |
+ + + + -+ +
| 1 | Alex | Manager | Sales | 45000 |
| 4 | Dev | Manager | Production | 45000 |
| 6 | Felix | HR Manager | HR | 42000 |
+ + + + -+ +
3 rows in set (0.00 sec)
mysql> -- Update the salary of employee with ID 6
mysql> UPDATE tblEmployee SET Salary = 65000.00 WHERE EmpID = 6;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Source Code
Sql
config.php
<?php session_start();
$password,$dbname);
<?php
include "config.php";
if(isset($_POST['but_submit'])){
$uname = mysqli_real_escape_string($con,$_POST['txt_uname']);
$password = mysqli_real_escape_string($con,$_POST['txt_pwd']);
$result = mysqli_query($con,$sql_query);
$row = mysqli_fetch_array($result);
}else{
?>
<html>
<head>
</head>
<body>
<div class="container">
<div id="div_login">
<h1>Login</h1>
<div>
</div>
<div>
</div>
<div>
</div>
</div>
</form>
</div>
</body>
</html>
style.css
/* Container */
/* Login */ #div_login{
height: 270px;
font-family: sans-serif;
padding: 7px;
width: 100px;
color: white;
}
Home.php
<?php
include "config.php";
header('Location: index.php');
// logout if(isset($_POST['but_logout'])){
session_destroy();
header('Location: index.php');
?>
<!doctype html>
<html>
<head></head>
<body>
<h1>Homepage</h1>
</form>
</body>
</html>
CONFIG.PHP
<?php
include "config.php";
header('Location: index.php');
// logout if(isset($_POST['but_logout'])){
session_destroy();
header('Location: index.php');
?>
<!doctype html>
<html>
<head></head>
<body>
<h1>Homepage</h1>
</form>
</body>
</html>
Output:
ADDITIONAL PROGRAMS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
</head>
<body>
<h2>Simple Calculator</h2>
<form method="post" action="">
<label for="num1">Number 1:</label>
<input type="text" name="num1" required></br></br>
<label for="num2">Number 2:</label>
<input type="text" name="num2" required></br></br>
<label for="operation">Operation:</label>
<select name="operation" required>
<option value="add">Addition</option>
<option value="subtract">Subtraction</option>
<option value="multiply">Multiplication</option>
<option value="divide">Division</option>
</select>
<button type="submit">Calculate</button>
</form>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Get user inputs
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$operation = $_POST['operation'];
switch ($operation) {
case 'add':
$result = $num1 + $num2;
break;
case 'subtract':
$result = $num1 - $num2;
break;
case 'multiply':
$result = $num1 * $num2;
break;
case 'divide':
if ($num2 != 0) {
Sql
config.php
<?php session_start();
$password,$dbname);
<?php
include "config.php";
if(isset($_POST['but_submit'])){
$uname = mysqli_real_escape_string($con,$_POST['txt_uname']);
$password = mysqli_real_escape_string($con,$_POST['txt_pwd']);
$result = mysqli_query($con,$sql_query);
$row = mysqli_fetch_array($result);
}else{
?>
<html>
<head>
</head>
<body>
<div class="container">
<div id="div_login">
<h1>Login</h1>
<div>
</div>
<div>
</div>
<div>
</div>
</div>
</form>
</div>
</body>
</html>
style.css
/* Container */
.container{ width:40%;
margin:0 auto;
/* Login */ #div_login{
height: 270px;
margin: 0 auto;
font-family: sans-serif;
padding: 5px;
padding: 7px;
width: 100px;
HOME.PHP
<?php
include "config.php";
header('Location: index.php');
// logout if(isset($_POST['but_logout'])){
session_destroy();
header('Location: index.php');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
margin: 20px;
}
h1 {
text-align: center;
flex-wrap: wrap;
justify-content: space-around;
.movie {
width: 200px;
color: white;
background:#1100ff; margin:0;
display:flex;
body{
margin:0;
padding:0;
form{
display:flex; height:1.1em;
}
</style>
</head>
<body>
<div id="nav">
</form>
</div>
<div class="movie-listings">
<div class="movie">
<h2>Movie 1</h2>
</div>
<div class="movie">
<h2>Movie 2</h2>
</div>
</div>
</body>
</html>
Output: