Tuesday, February 18, 2020

Echo Statement in PHP

I wrote this simple program using PHP programming language to show how to use the echo statement in PHP.

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
echo "<h1>Welcome To PHP Programming</h1>";
echo("<h2>Can you visit www.jakerpomperada.blogspot.com </h2><br>");
echo "<i> End of Program </i>"
?>


Wednesday, February 12, 2020

Fetch Records From Two Tables Using PHP and MySQLi

I wrote this code to show how to use an inner join to fetch records from two tables in the database using PHP and MySQL. The code is very easy and easy to understand for beginners in PHP and MySQL programming.

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

inner_join.sql

SELECT tbl_info.employee_id,tbl_info.name,tbl_info.position,tbl_contacts.telephone,tbl_contacts.mobile,tbl_contacts.email FROM tbl_info INNER JOIN tbl_contacts ON tbl_info.employee_id  = tbl_contacts.employee_id 

display.php

<html>
<title> Display Records </title>
<body>
 <style type="text/css">
    
  body {
   font-family: arial;
   size: 12px
  }

 </style>


<?php
   $dbhost = 'localhost';
   $dbuser = 'root';
   $dbpass = '';
   $dbname = 'employees';
   $conn = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname);
   
   if(! $conn ) {
      die('Could not connect: ' . mysqli_error());
   }
   echo 'Connected successfully</br>';
   $sql = 'SELECT tbl_info.employee_id,tbl_info.name,tbl_info.position,tbl_contacts.telephone,tbl_contacts.mobile,tbl_contacts.email FROM tbl_info INNER JOIN tbl_contacts ON tbl_info.employee_id  = tbl_contacts.employee_id ';
   
   if($result = mysqli_query($conn, $sql)) {
      if(mysqli_num_rows($result) > 0) {
         echo "<table>";
         echo "<tr>";
         echo "<th>EMPLOYEE ID</th>";
         echo "<th>NAME</th>";
         echo "<th> JOB POSITION</th>";
         echo "<th>TELEPHONE</th>";
         echo "<th>MOBILE</th>";
         echo "<th>EMAIL</th>";
         echo "</tr>";
         
         while($row = mysqli_fetch_array($result)){
            echo "<tr>";
            echo "<td>" . $row['employee_id'] . "</td>";
            echo "<td>" . $row['name'] . "</td>";
echo "<td> " . $row['position'] . "</td>";
            echo "<td>" . $row['telephone'] . "</td>";
            echo "<td>" . $row['mobile'] . "</td>";
            echo "<td>" . $row['email'] . "</td>";
            
            echo "</tr>";
         }
         echo "</table>";
         mysqli_free_result($result);
      } else {
         echo "No records matching your query were found.";
      }
   } else {
      echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
   }
   mysqli_close($conn);
?>

</body>
</html>

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 */;




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");
        
        
    }
}