Wednesday, February 12, 2020

Insert Records in Two Tables in PHP and MySQL

I wrote this code for my capstone project in my studies that enable the user to save records in two different tables using PHP and MySQL. I try to do some research on the Internet to find this code but fail so I decided to write one for my self and to share with other people who are in need of this code.

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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/



Sample Program Output


Program Listing

index.php

<?php
if(count($_POST)>0) {
require_once("db.php");

$emp_id     = strtoupper($_POST['employee_id']);
$emp_name       = strtoupper($_POST['emp_name']);
$emp_position = strtoupper($_POST['position']);

            /* Second Table */
            $emp_telephone  = $_POST['telephone'];
$emp_mobile     = $_POST['mobile']; 
            $emp_email      = strtolower($_POST['email']); 

$sql_one = "INSERT INTO tbl_info(employee_id,name,position) 
    VALUES('$emp_id','$emp_name','$emp_position')";

    /* Second Table Query */

$sql_two = "INSERT INTO tbl_contacts(employee_id,telephone,mobile,email) 
    VALUES('$emp_id','$emp_telephone','$emp_mobile','$emp_email')";


mysqli_query($conn,$sql_one);
mysqli_query($conn,$sql_two);


$current_id = mysqli_insert_id($conn);
$two_id = mysqli_insert_id($conn);
if(!empty($current_id) && !empty($two_id)) {
$message = "New Employee Record Added Successfully";
} else
{
$message = "Error Try Again";
}
}
?>
<html>
<head>
<title>Add New Employee Record</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<form name="frmUser" method="post" action="">
<div style="width:500px;">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<table border="0" cellpadding="10" cellspacing="0" width="500" align="center" class="tblSaveForm">
<tr class="tableheader">
<td colspan="2">Add New Employee Record</td>
</tr>
<tr>
<td><label>Employee ID</label></td>
<td><input type="text" name="employee_id" class="txtField"></td>
</tr>
<tr>
<td><label>Name</label></td>
<td><input type="text" name="emp_name" class="txtField"></td>
</tr>
<tr>
<td><label>Position</label></td>
<td><input type="text" name="position" class="txtField"></td>
</tr>
<tr>
<td><label>Telephone</label></td>
<td><input type="text" name="telephone" class="txtField"></td>
</tr>
<tr>
<td><label>Mobile</label></td>
<td><input type="text" name="mobile" class="txtField"></td>
</tr>
<tr>
<td><label>Email</label></td>
<td><input type="text" name="email" class="txtField"></td>
</tr>

<tr>
<td colspan="2"><input type="submit" name="submit" value="Submit" class="btnSubmit"></td>
</tr>
</table>
</div>
</form>
</body></html>

style.css

body {
font-family:Arial;
}
input {
font-family:Arial;
font-size:14px;
}
label{
font-family:Arial;
font-size:14px;
color:#999999;
}
.tblSaveForm {
border-top:2px #999999 solid;
background-color: #f8f8f8;
}
.tableheader {
background-color: #fedc4d;
}
.tablerow {
background-color: #A7D6F1;
color:white;
}
.btnSubmit {
background-color:#fd9512;
padding:5px;
border-color:#FF6600;
border-radius:4px;
color:white;
}
.message {
color: #FF0000;
text-align: center;
width: 100%;
}
.txtField {
padding: 5px;
border:#fedc4d 1px solid;
border-radius:4px;
}
.evenRow {
background-color: #E2EDF9;
font-size:12px;
color:#101010;
}
.evenRow:hover {
background-color: #ffef46;
}
.oddRow {
background-color: #B3E8FF;
font-size:12px;
color:#101010;
}
.oddRow:hover {
background-color: #ffef46;
}
.tblListForm {
border-top:2px #999999 solid;
}
.listheader {
background-color: #fedc4d;
font-size:12px;
font-weight:bold;
}
.link{
text-decoration:none;
color:#5e8fc7;
font-size:11px;
}

employees.sql

/*
SQLyog Ultimate v10.00 Beta1
MySQL - 5.5.5-10.1.38-MariaDB : Database - employees
*********************************************************************
*/


/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`employees` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `employees`;

/*Table structure for table `tbl_contacts` */

DROP TABLE IF EXISTS `tbl_contacts`;

CREATE TABLE `tbl_contacts` (
  `id_contact` int(15) NOT NULL AUTO_INCREMENT,
  `employee_id` varchar(50) DEFAULT NULL,
  `telephone` varchar(100) DEFAULT NULL,
  `mobile` varchar(100) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id_contact`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

/*Data for the table `tbl_contacts` */

insert  into `tbl_contacts`(`id_contact`,`employee_id`,`telephone`,`mobile`,`email`) values (1,'ABC1878','4335081','09173084360','jakerpomperada@gmail.com'),(2,'ABC1878','4335081','09173084360','jakerpomperada@gmail.com'),(3,'XYZ4545','546565656','56565656565','larry_emol@gmail.com');

/*Table structure for table `tbl_info` */

DROP TABLE IF EXISTS `tbl_info`;

CREATE TABLE `tbl_info` (
  `id_info` int(15) NOT NULL AUTO_INCREMENT,
  `employee_id` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `position` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id_info`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

/*Data for the table `tbl_info` */

insert  into `tbl_info`(`id_info`,`employee_id`,`name`,`position`) values (3,'ABC1878','JAKE','PROGRAMMER'),(4,'ABC1878','JAKE POMPERADA','WEB DEVELOPER'),(5,'XYZ4545','LARRY EMOL','VISUAL BASIC PROGRAMMER');

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


Monday, February 10, 2020

Decimal To Binary Number Converter

I wrote this program that will ask the user to give the decimal number and then the program will convert the given decimal number into binary number equivalent using the 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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.


Sample Program Output


Program Listing

binary.c

#include<stdio.h>
#include<conio.h>

int main()
{
long int d;
int i=0,a[25],j;
printf("\tDecimal To Binary Number Converter");
printf("\n\n");
printf("Enter the Decimal No.:");
scanf("%d",&d);
while(d>0)
{
a[i]=d%2;
d=d/2;
i++;
}
printf("Binary Number Equivalent : ");
for (j=i-1;j>=0;j--)
printf("%d",a[j]);
getch();
}



Wednesday, February 5, 2020

Do You Want To Continue in C

A simple program to show you how to integrate do you want to continue option 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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/


Program Listing

/* sum.c
   Written By: Jake R. Pomperada,MAED-IT
   September 19, 2019  */

#include <stdio.h>
#include <ctype.h>

int main() {
int x=0,y=0,sum=0;
char ch;
do {
printf("\n");
printf("\tAddition of Two Numbers Using Do While in C");
printf("\n\n");
printf ("\tEnter the first number : ");
scanf ("%d",&x);
printf ("\tEnter the second number : ");
scanf ("%d",&y);
sum=x+y;
printf("\n");
printf ("\tThe total number is: %d\n",sum);
printf("\n\n");
printf ("\tDo you want to repeat the operation Y/N: ");
scanf (" %c", &ch);
} while (toupper(ch) == 'Y');
printf("\n\n");
printf ("\tEnd of Program");
printf("\n\n");
}

School Title in Java

A simple School title I wrote using Java programming language while I am learning Java.

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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/


Program Listing

MySchool.java


public class MySchool {
 
    public static void main(String[] args) 
    {
        System.out.println("@      @  @       @  @@@@@@@        @@@@@@@");
        System.out.println("@      @  @ @     @  @     @        @      @");
        System.out.println("@      @  @  @    @  @     @        @     @");
        System.out.println("@      @  @   @   @  @     @ @@@@@@ @@@@@@   ");
        System.out.println("@      @  @    @  @  @     @        @     @");
        System.out.println("@      @  @     @ @  @     @        @      @");
        System.out.println("@@@@ @@@@  @       @  @@@@@@@        @       @");
       
        System.out.println("\nAlma Mater Hymn");
        System.out.println("To thee our Alma Mater Dear");
        
        
    }
}

Friday, January 31, 2020

Palindrome Number Checker in C++

Palindrome Number Checker in C++

I wrote this program that will ask the user to give integer and then the program will determine and check if the given number is a palindrome or not a palindrome using a 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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/



Sample Program Output



Program Listing

palindrome.cpp


#include <iostream>
#include <stdlib.h>

using namespace std;


int main()
{
    int n=0,num=0,digit=0,rev=0;
    
    cout <<"\n\n";
    cout <<"\tPalindrome Number Checker in C++ ";
    cout <<"\n\n";
    cout <<"\tGive a Positive Number : ";
    cin >> num;
    
    n = num;
    
    do {
        digit = num % 10;
        rev   = (rev * 10) + digit;
        num = num / 10;
        } while (num !=0);
        
    cout << "\tThe reverse of number is " << rev <<"\n";
    cout <<"\n\n";
    if (n == rev) {
          cout << "\tThe given number " << n<< " is a Palindrome.";
          }
         else {
                    cout << "\tThe given number " << n << " is  Not a Palindrome.";    
              }
                     
    cout <<"\n\n";
    cout << "\tEnd of the Program"; 
    cout <<"\n\n";     
    system("pause");
     }
     





Leap Year Checker in C++

Leap Year Checker in C++

I wrote this simple program in C++ to ask the user to give a year and then the program will check and determine if the year is a leap year or not a leap year.

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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/




Sample Program Output


Program Listing

leap_year.cpp

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    int year=0;

    cout <<"\n\n";
    cout <<"\tLeap Year Checker in C++";
    cout <<"\n\n";
    cout <<"\tGive a Year : ";
    cin >> year;
    cout <<"\n\n";
        
    if (year % 4 == 0) 
    {
      if (year % 100 == 0) 
       {
          if (year % 400 == 0)
               cout <<"\t"<< year << " is a Leap Year.";
             else
               cout <<"\t"<< year << " is Not a Leap Year.";              
       }       
     else 
        cout <<"\t"<< year << " is a Leap Year.";
        }
     else 
      cout <<"\t"<< year << " is Not a Leap Year.";    
      
    cout <<"\n\n";
    cout <<"\tEnd of Program";
    cout <<"\n\n";  
    system("pause");
}




Thursday, January 23, 2020

Headings in Tables in HTML

A simple code that will demonstrate how to use and declare headings in a table in HTML.

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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/


Program Listing

index.htm

<!DOCTYPE html>
<html>
    <body>
        <head><title>Headings in table</title></head>
    </body>
        <table border="1">
                <tr>
                    <th>Heading</th>
                    <th>Another Heading</th>
                </tr>
                <tr>
                    <td>row 1, cell 1</td>
                    <td>row 1, cell 2</td>
                </tr>
                 <tr>
                    <td>row 1, cell 1</td>
                    <td>row 2, cell 2</td>
                </tr>
            
        </table>
</html>

Math Calculator in Java

A simple math calculator program that I wrote in Java 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 in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/


Program Listing

Math_Calculator.java


import java.util.*;

public class Math_Calculator {
    public static void main(String[] args){
    Scanner Input = new Scanner(System.in);
    System.out.println("Enter Number");
    System.out.println("1 - Addition");
    System.out.println("2 - Subtraction");
    System.out.println("3 - Division");
    System.out.println("4 - Multiplication");
    
    int choice = Input.nextInt();
    if(choice==1){
        System.out.println("Enter first number");
        double num1 = Input.nextDouble();
        System.out.println("Enter Second number");
        double num2 = Input.nextDouble();
        double sum = num1+num2;
        System.out.println("sum= " + sum);
        
        
        }
    else if(choice==2){
        System.out.println("Enter first number");
        double num1 = Input.nextDouble();
        System.out.println("Enter Second number");
        double num2 = Input.nextDouble();
        double difference = num1-num2;
        System.out.println("difference= " + difference);
        
       
        }
    else if(choice==3){
        System.out.println("Enter first number");
        double num1 = Input.nextDouble();
        System.out.println("Enter Second number");
        double num2 = Input.nextDouble();
        double qoutient = num1/num2;
        System.out.println("qoutient= " + qoutient);
        
        }
   else if(choice==4){
        System.out.println("Enter first number");
        double num1 = Input.nextDouble();
        System.out.println("Enter Second number");
        double num2 = Input.nextDouble();
        double product = num1*num2;
        System.out.println("product= " + product);
        }
       else{
            System.out.println("invalid");
       }
    }
}