Thursday, February 12, 2015

Decimal To Romal Numeral Converter in PHP

I would like to share with you a simple program that I wrote PHP as my programming language I called this program Decimal To Roman Numeral Converter in PHP. What this program will do is to ask the user to enter any number in integer format and then the user can select convert to roman numeral button to convert the decimal value to its roman numeral equivalent. The code is very short and simple I also added a function if the user give invalid value such as words, letters or even special character our program will not hang or mal function in such situation encounter.

 If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



Sample Output of Our Program

Program Listing

<html>
<title> Decimal To Roman Numeral Converter</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>


<?php
error_reporting(0);

$values = intval($_POST['value']);

if(isset($_POST['check'])) {

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a number.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }

 if ($values != " ") {

  $natural_roman = array(1000 => 'M', 500 => 'D', 100 => 'C', 50 => 'L', 10 => 'X', 5 => 'V', 1 => 'I');

    function convert_to_roman($natural)

    {

        global $natural_roman;

        reset($natural_roman);

        while (list($key, $value) = each($natural_roman))

        {

            while ($natural >= $key)

            {

                $natural -= $key;

                $rn .= $value;

            }

        }

        return str_replace(

                                array('DCCCC', 'CCCC', 'LXXXX', 'XXXX', 'VIIII', 'IIII'),        

                                array('CM', 'CD', 'XC', 'XL', 'IX', 'IV'),

                                $rn

                            );        

    }

    
   $results .=  "==== REPORT ==== ";
   $results .=  "<br><br>";
   $results .= "The number " .$values." it's Roman Numeral equivalent is "
               .convert_to_roman($values).".";
   
  
   }
   
    }
       
    

if(isset($_POST['clear'])) {
  $values=" "; 
  $results= " ";
  
}

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Decimal To Roman Numeral Converter</h2>
  <br>
<form action="" method="post">
 Enter a Sentence : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=10/>
 <br><br>
   <input type="submit" name="check" value="Convert To Roman Numeral" 
  title="Click here to convert decimal to roman numeral equivalent."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br>
<?php 
echo $results;
 ?>
  </body>
</html>


Wednesday, February 11, 2015

Upload and Display Picture in PHP and MySQL

In this article I would like to share with you a sample program that I wrote in PHP and MySQL how to upload and display picture from MySQL. This is very useful in creating employee's or student profile system that requires us to put an image of the student or the employee's in our database. The code is very simple and easy to understand in this code I also added a view page that the user can view and navigate the profile of the person using a simple HTML hyperlink.

 If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360


Thank you very much and Happy Productive Programming. 


Sample Output of Our Program



Tuesday, February 10, 2015

Number To Words Converter in PHP



   This program will ask the user to enter a number and then converts the given number into its words format in PHP. I also included a code that will check if the text field is empty and will inform the user to enter a number so that it can be convert into words.


 If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



Thank you very much and Happy Productive Programming. 




Sample Output of Our Program



Program Listing 

<html>
<title> Number To Words Converter</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>

<?php
 error_reporting(0);

 $values = $_POST['value1'];
 $num =  floatval($values);


if(isset($_POST['check'])) {

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a sentence.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }
  
   }
      
   $results .=  "==== DISPLAY RESULT ==== ";
   $results .=  "<br><br>";
   $results .= convert_number_to_words($num);

if(isset($_POST['clear'])) {
  $values= " "; 
  $results= "  ";
  $num=" ";
  
}

function  convert_number_to_words($number) {
    
    $hyphen      = '-';
    $conjunction = ' and ';
    $separator   = ', ';
    $negative    = 'negative ';
    $decimal     = ' point ';
    $dictionary  = array(
        0                   => 'zero',
        1                   => 'one',
        2                   => 'two',
        3                   => 'three',
        4                   => 'four',
        5                   => 'five',
        6                   => 'six',
        7                   => 'seven',
        8                   => 'eight',
        9                   => 'nine',
        10                  => 'ten',
        11                  => 'eleven',
        12                  => 'twelve',
        13                  => 'thirteen',
        14                  => 'fourteen',
        15                  => 'fifteen',
        16                  => 'sixteen',
        17                  => 'seventeen',
        18                  => 'eighteen',
        19                  => 'nineteen',
        20                  => 'twenty',
        30                  => 'thirty',
        40                  => 'fourty',
        50                  => 'fifty',
        60                  => 'sixty',
        70                  => 'seventy',
        80                  => 'eighty',
        90                  => 'ninety',
        100                 => 'hundred',
        1000                => 'thousand',
        1000000             => 'million',
        1000000000          => 'billion',
        1000000000000       => 'trillion',
        1000000000000000    => 'quadrillion',
        1000000000000000000 => 'quintillion'
    );
    
    if (!is_numeric($number)) {
        return false;
    }
    
    if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) {
        // overflow
        trigger_error(
            'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
            E_USER_WARNING
        );
        return false;
    }

    if ($number < 0) {
        return $negative . convert_number_to_words(abs($number));
    }
    
    $string = $fraction = null;
    
    if (strpos($number, '.') !== false) {
        list($number, $fraction) = explode('.', $number);
    }
    
    switch (true) {
        case $number < 21:
            $string = $dictionary[$number];
            break;
        case $number < 100:
            $tens   = ((int) ($number / 10)) * 10;
            $units  = $number % 10;
            $string = $dictionary[$tens];
            if ($units) {
                $string .= $hyphen . $dictionary[$units];
            }
            break;
        case $number < 1000:
            $hundreds  = $number / 100;
            $remainder = $number % 100;
            $string = $dictionary[$hundreds] . ' ' . $dictionary[100];
            if ($remainder) {
                $string .= $conjunction . convert_number_to_words($remainder);
            }
            break;
        default:
            $baseUnit = pow(1000, floor(log($number, 1000)));
            $numBaseUnits = (int) ($number / $baseUnit);
            $remainder = $number % $baseUnit;
            $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
            if ($remainder) {
                $string .= $remainder < 100 ? $conjunction : $separator;
                $string .= convert_number_to_words($remainder);
            }
            break;
    }
    
    if (null !== $fraction && is_numeric($fraction)) {
        $string .= $decimal;
        $words = array();
        foreach (str_split((string) $fraction) as $number) {
            $words[] = $dictionary[$number];
        }
        $string .= implode(' ', $words);
    }
    
    return $string;

}
  


?>

<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Number To Words Converter in PHP</h2>
  <br>
<form action="" method="post">
 Enter a Sentence : <input type="text" name="value1"    value="<?php echo $values; ?>" autofocus  size=10/>
 <br><br>
   <input type="submit" name="check" value="Convert to Words" 
  title="Click here to convert number into words."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br>
<?php 
echo $results;
 ?>
  </body>
</html>


DOWNLOAD SOURCE CODE HERE

Monday, February 9, 2015

Vowels and Consonants Counter in PHP

In this article I would like to share with you a program that I wrote in PHP I called this program vowel and consonants counter. I wrote this similar program in C,C++ and Java I want to convert it in PHP so I wrote this code in my spare time. What the program will do is to ask the user to enter a sentence it doesn't matter if the user type small or capital letters our program has the ability to count the letters as long it is a valid vowel or consonants character.

I also added some form validation to make sure that the user will type something in our text field rather than it leave a black value in our text field. I hope you will find our program useful in your learning PHP programming.

If you have some questions please send me an email at jakerpomperada@yahoo.comand jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360.

Thank you very much and Happy Productive Programming.






Sample Output of Our Program

Program Listing


<html>
<title> Vowels and Consonants Counter</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>


<?php

error_reporting(0);
$values = $_POST['value'];
if(isset($_POST['check'])) {

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a sentence.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }
 if ($values != " ") {
   $total_vowels = 0; $total_consonants=0;

      $vowels = Array('a','e','i','o','u','A','E','I','O','U');
      $vowels = Array('a','e','i','o','u','A','E','I','O','U');
      $consonants = Array('b','c','d','f','g','h','j','k','l','m'
                ,'n','p','q','r','s','t','v','w','x','y','z'
                ,'B','C','D','F','G','H','J','K','L','M'
                ,'N','P','Q','R','S','T','V','W','X','Y','Z');

for ($b=0;$b<strlen($values);$b++)
{
    for ($a = 0;$a<10;$a++)
        if ($values[$b] == $vowels[$a])
        {
            $total_vowels++;
            break;
        }

 for ($a = 0;$a<42;$a++)
        if ($values[$b] == $consonants[$a])
        {
            $total_consonants++;
            break;
        }
}
   $results .=  "==== REPORT ==== ";
   $results .=  "<br><br>";
   $results .= "The sentence is   :=>   " .$values."<br><br><br>";
   $results .= "Total Consonants  :=>  " .$total_consonants."<br>";   
   $results .=  "Total Vowels     :=>  " .$total_vowels."<br>";
  
   }
  
  
    }
       
    

if(isset($_POST['clear'])) {
  $values=" "; 
  $results= " ";
  
}

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Vowels and Consonants Counter</h2>
  <br>
<form action="" method="post">
 Enter a Sentence : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=50/>
 <br><br>
   <input type="submit" name="check" value="Find Vowels and Consonants" 
  title="Click here to know the number of Vowels and Consonants in a given sentence."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br>
<?php 
echo $results;
 ?>
  </body>
</html>


DOWNLOAD SOURCE CODE HERE

Friday, February 6, 2015

Factorial Number Solver in PHP

This code will compute for the factorial value of the given number by our user. What is good about my code is that I included value validation to check if the given number is truly an integer not special character or letters or words before our program will solve the factorial equivalent of the number which is given by our user.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360.

Thank you very much and Happy Productive Programming.





Program Listing

<html>
<title> Factorial Number Solver </title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);

$values = $_POST['value'];

 // function to solve of the factorial value

 function factorial_solve($variable) {
    if ($variable == 0)
        return 1;
    else
        return($variable * factorial_solve($variable - 1));
}

if(isset($_POST['check'])) {

     if (ctype_alpha($values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
  $values="";
 }
 
else if(preg_match('#[^a-zA-Z0-9]#', $values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
        $values="";
      
}

    else  if ($values=="") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a integer value.');";
  echo "</script>";
  $values="";
           }
else { 
      $title = "The factorial value of ".$values." is " .factorial_solve($values).".";
       }  
   }  

if(isset($_POST['clear'])) {
  $values=" "; 
  $title=" ";
  
}

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Factorial Number Solver </h2>
  <br>
<form action="" method="post">
 Enter a Number : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=20/>
   <input type="submit" name="check" value="Find Factorial Value" 
  title="Click here to know the factorial value of the given number."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>

<br> <br>

<?php 
echo $title;
 ?>
  </body>

</html>


DOWNLOAD SOURCE CODE HERE

Thursday, February 5, 2015

Swap a Two Numbers in PHP

In this article I would like to share with you a simple program that will ask the user to enter two numbers and then our program will swap the arrangement of numbers using PHP as our programming language. One of the strength of PHP it has many built in data structure function that makes programming much easier compared with traditional programming language that requires you to wrote your own function or methods just to achieve the same results. I hope you will find my work useful in your learning in PHP.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360.

Thank you very much and Happy Productive Programming.


Sample Output of Our Program

Program Listing

<html>
<head>
</head>
<body>
<?php include 'template-parts/header.php' ?><br>
<div class="container home">
<?php
    $value1 = $_POST['num1'];
    $value2 = $_POST['num2'];
    if(isset($_POST['solve']))
    {
    $result1 = "<font size='4' color='blue' > Original Arrangement  :=> "
              .$value2. " and ".$value1.".</font> <br><br>";
list($value2, $value1) = array($value1, $value2);
$result2 = "<font size='4' color='blue' > After Swapping        :=> "
            .$value2. " and ".$value1.".</font> <br>";
    }
if (isset($_POST['clear']))
{
$value1=""; $value2=""; 
$result1=""; $result2="";
}
?>
<form action="index.php" method="post">
<font size="6" color="blue">
<label> Enter First Number: </label>
<input type="text" placeholder="first number" autofocus name="num1" value="<?php echo $value1; ?>" />
<br />
<label> Enter Second Number: </label>
<input type="text" placeholder="second number"  name="num2" value="<?php echo $value2; ?>"  />
<br />
 </font>
<input type="submit" name="solve" value="Swap"
 title="Click here to swap values." class="btn btn-info">
<input type="submit" name="clear" value="Clear"
 title="Click here to clear text box." class="btn btn-info">
</form>
<?php
 echo "<br><br>";
 echo $result1;
 echo $result2;
 ?>
</div>
</body>
</html>



Monday, February 2, 2015

Decimal To Octal Conversion in PHP

In this article I would like to share with you how to convert decimal into octal value using php as your programming language the code is very easy to understand because in PHP there is already a built in function to convert decimal into octal equivalent using this statement sprintf("%o",$bin).

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360.

Thank you very much and Happy Productive Programming



Sample Output of Our Program



Friday, January 30, 2015

Delete a Record in PHP and Microsoft Access

During my learning process how to create basic CRUD or Create, Retrieve, Update and Delete in PHP and Microsoft Access I wrote a code how to delete or remove a single record from our table in Microsoft Access. The code is based in SQL statement I intended my work for beginners in PHP and MS Access database programming and development.

I hope you will find my work useful and beneficial in learning how to create a database application using PHP and Microsoft Access as your database management solution in your business problems.

If you have some questions please send me an email at jakerpomperada@yahoo.comand jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360.

Thank you very much and Happy Productive Programming.



Sample Output of Our Program