Friday, July 9, 2021

Simple Room Reservation System in PHP

 A simple room reservation system that I wrote using PHP and MySQL.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

reservation.sql

-- phpMyAdmin SQL Dump

-- version 5.1.0

-- https://www.phpmyadmin.net/

--

-- Host: 127.0.0.1

-- Generation Time: Jul 07, 2021 at 01:49 PM

-- Server version: 10.4.18-MariaDB

-- PHP Version: 8.0.3


SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

START TRANSACTION;

SET time_zone = "+00:00";



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8mb4 */;


--

-- Database: `room_reservation`

--


-- --------------------------------------------------------


--

-- Table structure for table `reservations`

--


CREATE TABLE `reservations` (

  `id` int(11) NOT NULL,

  `name` varchar(100) NOT NULL,

  `room` varchar(100) NOT NULL,

  `date_reserved` varchar(100) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


--

-- Indexes for dumped tables

--


--

-- Indexes for table `reservations`

--

ALTER TABLE `reservations`

  ADD PRIMARY KEY (`id`);


--

-- AUTO_INCREMENT for dumped tables

--


--

-- AUTO_INCREMENT for table `reservations`

--

ALTER TABLE `reservations`

  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

COMMIT;


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


index.php

<?php
    $local =  "localhost"; // Host Name
    $user  =  "root"; // Host Username
    $pass  =  ""; // Host Password
    $db    =  "room_reservation"; // Database Name

    // Establish connection to the database
    $con = new mysqli($local, $user, $pass, $db);
    // if there is a problem, show error message
    if ($con->connect_errno) {
        echo "Failed to connect to MySQL: " . $con->connect_error;
        exit();
    }

    if(isset($_POST["btnReserve"])) {
        $name = trim($con->real_escape_string($_POST["txtName"]));
        $room = trim($con->real_escape_string($_POST["txtRoom"]));
        $date = trim($con->real_escape_string($_POST["txtDate"]));

        if ($stmt = $con->prepare("INSERT INTO `reservations`(`name`, `room`, `date_reserved`) VALUES (?, ?, ?)")) {
            $stmt->bind_param("sss", $name, $room, $date);
            $stmt->execute();
            $stmt->close();
        } else {
            die('prepare() failed: ' . htmlspecialchars($con->error));
        }
    }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Simple Room Reservation System in PHP</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <script src="https://kit.fontawesome.com/c82e9a37b7.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.standalone.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
    <style>
        body {
            background: #e9ecef;
            font-family: sans-serif;
        }
    </style>
</head>
<body class="py-5">
    <main class="container">
        <div class="row">
            <div class="offset-2 col-8 font-size-xl">
                <div class="bg-secondary text-light rounded  text-center p-3">
                    <h2 class="font-weight-bold">Simple Room Reservation System in PHP</h2>
                    <h3>&#187; Jake R. Pomperada, MAED-IT, MIT &#171;</h3>
                </div>
                <form action="" method="post" class="my-5">
                    <div class="form-group">
                        <label for="txtName">Name:</label>
                        <input type="text" class="form-control" name="txtName" required>
                    </div>
                    <div class="form-group">
                        <label for="txtRoom">Room Type:</label>
                        <select class="form-control" name="txtRoom" required>
                            <option value="Regular">Regular</option>
                            <option value="Deluxe">Deluxe</option>
                            <option value="VIP Suite">VIP Suite</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="txtDate">Date:</label>
                        <input type="text" class="form-control datepicker" name="txtDate" id="txtDate" required>
                    </div>
                    <button type="submit" class="btn btn-dark" name="btnReserve">Reserve Now!</button>
                </form>
            </div>
        </div>
        <div class="row mt-5">
            <div class="offset-2 col-8 mt-5">
                <table class="table table-striped table-bordered" id="datatable">
                    <legend class="bg-secondary p-3 text-light text-center rounded">
                        <h2 class="m-0">Reservations Table</h2>
                    </legend>
                    <thead>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Room Type</th>
                        <th>Date</th>
                    </thead>
                    <tbody>
                        <?php                         
                            // Display database table data
                            if ($stmt = $con->prepare("SELECT * FROM `reservations`")) {
                                $stmt->execute();
                                $result = $stmt->get_result();
                                while ($row = $result->fetch_assoc()) {
                                    echo "<tr>".
                                            "<td>".$row["id"]."</td>".
                                            "<td>".$row["name"]."</td>".
                                            "<td>".$row["room"]."</td>".
                                            "<td>".$row["date_reserved"]."</td>".
                                        "</tr>";
                                }
                                $stmt->close();
                            } else {
                                die('prepare() failed: ' . htmlspecialchars($con->error));
                            }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </main>

    <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
    <script>
        $(document).ready(function() {
            $('.datepicker').datepicker({
                autoclose: true,
                todayHighlight: true,
                todayBtn: 'linked',
                startDate: 'today',
            });

            $('#datatable').DataTable();

            $('#txtDate').keypress(function(e) {
                e.preventDefault();
            });
        });
    </script>
</body>
</html>

Wednesday, July 7, 2021

Simple Math Calculator in JavaScript

Simple Math Calculator in JavaScript

 A simple math calculator that I wrote using JavaScript programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

index.htm

<html>

<style>

body {

  background-color:lightgreen;

  font-family:arial;

  font-size:20px;

  font-weight:bold;

  color:blue;

}

p {

  font-family:arial;

  font-size:20px;

  font-weight:bold;

  color: blue;

  }

  

div.text { 

  margin: 0; 

  padding: 0; 

  padding-bottom: 1.25em; 


div.text label { 

  margin: 0; 

  padding: 0; 

  display: block; 

  font-size: 100%; 

  padding-top: .1em; 

  padding-right: 2em; 

  width: 8em; 

  text-align: right; 

  float: left; 


div.text input, 

div.text textarea { 

  margin: 0; 

  padding: 0; 

  display: block; 

  font-size: 100%; 


input:active, 

input:focus, 

input:hover, 

textarea:active, 

textarea:focus, 

textarea:hover { 

  background-color: lightyellow; 

  border-color: yellow; 


</style>  

<body><br>

<h2 align="left"> Simple Math Calculator in JavaScript </h2>

<br>

<div class="text"> 

    <label for="val1">Item Value No. 1</label> 

    <input type="text" size="5" name="val1" id="val1" maxlength="5"/> 

</div> 


<div class="text"> 

    <label for="val2">Item Value No. 2</label> 

    <input type="text" size="5" name="val2" id="val2" maxlength="5"/> 

</div> 

<button onclick="compute()" title="Click here to find the result."> Ok </button> &nbsp;&nbsp;&nbsp;&nbsp;

<button onclick="clear_all()" title="Click here to clear the text fields."> Clear </button>

<br><br><br>

<p id="display1"> </p>

<p id="display2"> </p>

<p id="display3"> </p>

<p id="display4"> </p>


<script>

function compute()

{


var val1 = document.getElementById('val1').value;

var val2 = document.getElementById('val2').value;


var sum = parseInt(val1) + parseInt(val2);

var subtract = parseInt(val1) - parseInt(val2);

var product = parseInt(val1) * parseInt(val2);

var quotient = parseInt(val1) / parseInt(val2);



 document.getElementById("display1").innerHTML = "The sum of " + val1 + " and " + val2 + " is " + sum + ".";

 document.getElementById("display2").innerHTML = "The difference between " + val1 + " and " + val2 + " is " + subtract + ".";

 document.getElementById("display3").innerHTML = "The product between " + val1 + " and " + val2 + " is " + product + ".";

 document.getElementById("display4").innerHTML = "The quotient between " + val1 + " and " + val2 + " is " + quotient + ".";


}


function clear_all()

{

document.getElementById("display1").innerHTML ="";

document.getElementById("display2").innerHTML ="";

document.getElementById("display3").innerHTML ="";

document.getElementById("display4").innerHTML =""; 

document.getElementById("val1").value="";

document.getElementById("val2").value="";

document.getElementById("val1").focus();

}

</script>

</body>

<html>

Tuesday, July 6, 2021

Basic OOP in Python

Basic OOP in Python

 In this tutorial I will show you how to write basic object oriented programming in Python programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

class Dog:
#class attribute
breed = "German Shepherd"
#instance attributes (pangalan,edad)
def __init__(self,name,age): # name and age are called paramaters
self.pangalan = name
self.edad = age
#instance method
def run(self):
return f"{self.pangalan} is running"

#instance objects
preppy = Dog("Preppy",3) #instantation statement
browny = Dog("Browny",8) #instantation statement


#accessing instance attributes

print()
print("\tBasic OOP in Python")
print()
print(f"{preppy.pangalan} is {preppy.edad} years old")
print(f"{browny.pangalan} is {browny.edad} years old")
#accessing class attribute
print(f"Preppy is a {preppy.breed}")
print(f"Browny is also a {browny.breed}")
#accesing instance method using preppy object
print(preppy.run())
#accesing instance method using browny object
print(browny.run())
print()
print("\tEnd of Program")
print()

Crop Images in a Circle Shape Using Photoshop

Sunday, July 4, 2021

Multiplication Table Using For Statement in Python

Multiplication Table Using For Statement in Python

 A simple multiplication table generated using for statement in Python programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Program Listing

# Multiplication_Table_For.py
# Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.com and www.jakerpomperada.blogspot.com
# jakerpomperada@gmail.com
# Bacolod City, Negros Occidental

print("-" * 60)
print("\tMULTIPLICATION TABLE USING FOR STATEMENT IN PYTHON")
print("-" * 60)

for a in range(1, 13):
for n in range(1, 13):
print("%4d" % (a * n), end=' ')
print()

print("-" * 60)

Friday, July 2, 2021

Multiplication Table in C#

A simple multiplication table that I wrote using C# programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace Multiplication_Table

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("\n");

            Console.WriteLine("\t\tMultiplication Table in C#");

            for (int i = 1; i <= 12; i++)

            {

                Console.WriteLine("\n");


                for (int j = 1; j <= 12; j++)

                {

                    Console.Write("{0,4}", i * j);

                }


            }


            Console.Read();

        }

    }

}


Multiplication Table in Modern C++

Multiplication Table in Modern C++

 I simple multiplication table that I wrote using Modern C++ approach.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Program Listing

// multiplication_table.cpp

// Jake Rodriguez Pomperada, MAED-IT,MIT

// www.jakerpomperada.blogspot.com and www.jakerpomperada.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines.


#include <iostream>

#include <iomanip>

#include <string>


int main()

{

  const std::string line(60, '-');


  std::cout <<"\n";

  std::cout << line << "\n";

  std::cout << "\t\tMULTIPLICATION TABLE IN MODERN C++" << "\n";

  std::cout << line << "\n";


  for (int a = 1; a < 13; ++a)

  {

    for (int n = 1; n < 13; ++n)

    {

      std::cout << std::setw(4) << a*n << ' ';

    }

    std::cout << "\n";

  }

  std::cout << line << "\n";

}


Wednesday, June 30, 2021

Multiplication Table in Python

Multiplication Table in Python

 A simple multiplication table that I wrote using Python programming language I hope you will find my work useful.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

# Multiplication_Table.py
# Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.com and www.jakerpomperada.blogspot.com
# jakerpomperada@gmail.com
# Bacolod City, Negros Occidental

a = 1
print("-" * 60)
print("\t\t\t\tMULTIPLICATION TABLE ")
print("-" * 60)
while a < 13:
n = 1
while n <= 12:
print("%4d" % (a * n), end=' ')
n += 1
print()
a += 1
print("-" * 60)

Simple Interest Rate Solve in JavaScript

Simple Interest Calculator in JavaScript

 A simple interest calculator in JavaScript I wrote a long time ago while teaching JavaScript programming in one of the colleges here in the Philippines.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.






Program Listing

index.htm

<html>
<style>
body,p {

  font-family:arial;
  font-size:16px;
  font-weight:bolder;
 }
 
    .container {
        width: 450px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }

    </style>
<div class="container">
<body>
<h3> Simple Interest Calculator in JavaScript </h3>
<br/>Principal (P): Php
<input type="text" id="principal" name="principal">
<br>
<br/> Rate (R):
<input type="text" id="rate" name="rate">
<br>
<br/> Time (t):
<input type="text" id="time" name="time">
<br>
<br>
<button onclick="compute_interest()">Compute Interest</button>
<br><br>
<p id="demo"></p>

</div>
<script>
function Commas(n) {
    var parts=n.toString().split(".")
    return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : "");
}
  function compute_interest() {
    var  principal = document.getElementById("principal").value;
var  rate = document.getElementById("rate").value;
var  time = document.getElementById("time").value;
     rate2 = parseFloat(rate)/100;
amount_interest = parseFloat(principal) * (1+ (parseFloat(rate2)*time));
     
amt =amount_interest.toFixed(2);
display = Commas(amt);
results ="Amount to be paid is Php " + display+".";
     
      document.getElementById("demo").innerHTML = results;
  }
</script>
</body>
</html>


Multiplication Table in JavaScript

Multiplication Table in JavaScript

 A simple program to generate multiplication table using JavaScript programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

index.htm

<html>

<head>

<title>MULTIPLICATION TABLE </title>

</head>

<style>

body {

  font-family:arial;

  font-size:20px;

  }

 </style>  

<body>

<br>

<h3 align="center"> MULTIPLICATION TABLE</h3>

<script language="JavaScript">


document.write("<center><table border='1px'>");


for(var a = 1; a < 13; a++) {

    document.write("<tr style='height:40px'>");


for(var b = 1; b < 13; b++) {

    document.write("<td style='width:40px'><center><font size='4'>" 

+ a*b + "</center></font></td>");

}

document.write("</tr>");

}

document.write("</table></center>");


</script>

</head>

</body>

</html>