Monday, July 23, 2012

input type='image' $_POST problem while image sa submit button

When i used <input type="image' name="submit"/> as submit button and <input type="image' name="reject"/> as Reject button in a form ,i  notice that $_POST have no information about which button is clicked...
SOLUTION
Use a hidden field and set its value using javascript using a function 'onclick'.

For example:
<form>
<input type="text" name="name"/>
<input type="image' name="submit"  onclick="confirm('submit')"/>
 <input type="image' name="reject" onclick="confirm('reject')"/> 
<input type="hidden" name="suborrej">
</form>
<script type="text/javascript">
function confirm(status)
{
document.getElementById('suborrej').value=status;
}
</script>
Now you can check using php
if($_POST['suborrej']=='submit')
{
}
else
{
}

Monday, June 4, 2012

Create a number series like 1,12,234,4567... using php

1
1 2
2 3 4
4 5 6 7
7 8 9 10 11

<?php
  $n=5;$a = 1;
 
   for ($i = 1 ; $i <= $n ; $i++ )
   {
      for ( $c = 1 ; $c <= $i ; $c++ )
      {  
         if($c!=1)
         $a++;
         printf("%d ",$a);
        
      }
      printf("</br>");
   }
 ?>

Saturday, June 2, 2012

Sorting array of numbers using Insertion Sort in PHP (PHP Code)

 
Every repetition of insertion sort removes an element from the input data, inserting it into the correct position in the already-sorted list, until no input elements remain. The choice of which element to remove from the input is arbitrary, and can be made using almost any choice algorithm.


<?php
                
           $num=array(1,9,3,7,8,2,5,6);
                         function insertionsort($num)
                       {
                            for ($i=0;$i<=count($num)-1;$i++)
                            {
                                 for($j=0;$j<$i;$j++)
                                   {
                                       if($num[$j]>$num[$i])
                                      {
                                       $temp=$num[$i];
                                       $num[$i]=$num[$j];
                                        $num[$j]=$temp;
                                       }
                                 }
                                //var_dump($num);
                            }
                            return $num;
                       }
                        var_dump($num);
                        var_dump(insertionsort($num));

?>

 

 
 
array
  0 => int 1
  1 => int 9
  2 => int 3
  3 => int 7
  4 => int 8
  5 => int 2
  6 => int 5
  7 => int 6
array
  0 => int 1
  1 => int 9
  2 => int 3
  3 => int 7
  4 => int 8
  5 => int 2
  6 => int 5
  7 => int 6
array
  0 => int 1
  1 => int 3
  2 => int 9
  3 => int 7
  4 => int 8
  5 => int 2
  6 => int 5
  7 => int 6
array
  0 => int 1
  1 => int 3
  2 => int 7
  3 => int 9
  4 => int 8
  5 => int 2
  6 => int 5
  7 => int 6
array
  0 => int 1
  1 => int 3
  2 => int 7
  3 => int 8
  4 => int 9
  5 => int 2
  6 => int 5
  7 => int 6
array
  0 => int 1
  1 => int 2
  2 => int 3
  3 => int 7
  4 => int 8
  5 => int 9
  6 => int 5
  7 => int 6
array
  0 => int 1
  1 => int 2
  2 => int 3
  3 => int 5
  4 => int 7
  5 => int 8
  6 => int 9
  7 => int 6
array
  0 => int 1
  1 => int 2
  2 => int 3
  3 => int 5
  4 => int 6
  5 => int 7
  6 => int 8
  7 => int 9

Wednesday, May 30, 2012

Sorting numbers using bubble sort technique in php ( Sorting Code)

 

Bubble sort

A bubble sort, a sorting algorithm that continuously steps through a list, swapping items until they appear in the correct order.
Bubble sort is a simple sorting algorithm. The algorithm starts at the beginning of the data set. It compares the first two elements, and if the first is greater than the second, it swaps them. It continues doing this for each pair of adjacent elements to the end of the data set. It then starts again with the first two elements, repeating until no swaps have occurred on the last pass. This algorithm's average and worst case performance is O(n2), so it is rarely used to sort large, unordered, data sets. Bubble sort can be used to sort a small number of items (where its inefficiency is not a high penalty). Bubble sort may also be efficiently used on a list that is already sorted except for a very small number of elements. For example, if only one element is not in order, bubble sort will take only 2n time. If two elements are not in order, bubble sort will take only at most 3n time...
<?php
$num=array(1,9,3,7,8,2,5,6);
function sorter($num)
{
    for ($i=0;$i<=count($num)-1;$i++)
{
    if($num[$i]>$num[$i+1])
    {
        //echo $num[$i].':'.$num[$i+1].'<br>';
        $temp=$num[$i];
        $num[$i]=$num[$i+1];
        $num[$i+1]=$temp;
        $num=sorter($num);
    }
   
    }
    return $num;
}
var_dump($num);
var_dump(sorter($num));
   
?>

Create a number series like 1 21 321 4321 54321 654321

1
21
321
4321
54321
654321

<?php
for($i=1;$i<=6;$i++)
{
    $n='';
    for($j=$i;$j>0;$j--)
    {
        $n=$n.$j;
    }
    echo $n.'</br>';
}
?>

Create Letter Traingle like =>keralam,kerala,keral,kera,ker,ke,k

Create a pattern like this using php?
keralam
kerala
keral
kera
ker
ke
k

<?php
$state=array('k','e','r','a','l','a','m');

for($i=6;$i>=0;$i--)
{
    $st='';
    for($j=$i;$j>=0;$j--)
    {
        $st=$state[$j].$st;
    }
    echo $st.'</br>';
   
}
echo "</br>";
?>

KSRTC and Private Bus Timing at Info Park,Kakkanad,Ernakulam,Kerala/Technopark Trivandrum

                            Type          To              Via              Arr   Dep

GTech has requested Mr. Biju Prabhakar, IAS, Transport Secretary, to reinstate the bus service that existed prior to COVID. As all the IT parks are now registering a substantial increase in employee headcount after the pandemic, the requirement of public transport is becoming very important. We hope that this will ease the burden on employees who have been affected by the cancellation. GTech requested the bus facilities to be made available at the following places:-
 Technopark- Trivandrum 8.10 AM, 9.30 AM Kazhakoottam railway station to Technopark campus (connection to Malabar and Vanchinad Express ) 6 PM, 6.50 PM
 Technopark campus to Kazhakoottam railway station (connection to Parasuram and Malabar Express) 5.30 to 6 PM
 1) Technopark to Eastfort 
2) Technopark to Peroorkada
3) Technopark to Balaramapuram 
4) Technopark to Thirumala 
5) Technopark to Attingal 5.30 to 6 p.m. on Fridays 

1) Technopark to Ernakulam via Kottayam
 2) Technopark to Ernakulam via Alappuzha
 3) Technopark to Kazhakoottam Railway Station and back 
 Infopark- Kochi 7:45 a.m. to 10:30 a.m. 
1. Aluva-Kalamaserry-Infopark
 2. Paravoor, Edappally Toll, Unichira, BMC, Infopark
 3. Paravoor: Paravoor Kavala-Aluva-Kalamassery-Infopark
 4. Njarakkal, Vypin, Infopark 
5. Perumbavoor, Pallikkara, Vayana Sala, Edachira, and Infopark
 6. Muvattupuzha, Kolenchery, Puthencruz, Karimugal, Infopark
 7. Thodupuzha, Muvattupuzha, Infopark 
8. Chottanikkara, Karigachira, Irumpanam, and Infopark 
9. Vaikom; Thrippunithura; Irumpanam; Infopark 
10. Fort Kochi-Thevara-Infopark 
11. Aroor, Vyttila, Infopark 
12. Kakkanad-Chittethukara-CSEZ-Infopark phases 1 and 2—via Seaport Airport Road (shuttle service). Cyberpark, Kozhikode 8:30 a.m. and 5:06 p.m. daily 1. Kozhikode City Centre to Cyberpark 2. Cyberpark to Kozhikode City Centre


If you want to go urgently you have to pay RS:40 for Auto to reach at Kakkanad Bus Stop.

VENAD | CHERTHALA | VYTILLA  7.58 AM 8.00 AM
VoLvo | ALUVA HMT 7.58 AM | 6.05 AM]
VENAD ALAPUZHA CHERTHALA 7.58 AM | 8.10 AM
VOLVO KALOOR |MEENAKA 8.15AM | 8.20AMI
voLvo ALUVA 8.20 AM | 8.35AM
VENAD ALAPUZHA CHERTHALA 8.45 AM | 8.50 AM
VOLVO. | FORTCOCHI PALARIVATTAM | 9.10 AM | 9.15 AM§
VOLVO HMT 9.05 AM | 9.40 AM

IRUMBANAM KAKKANAD 10.410 AM | 10.11 AM

TRIPUNITHURA KAKKANAD 10.35 AM | 10.40 A



Saturday, May 26, 2012

1,121,12321,123454321 create pyramid using php

1st logic

1^2 = 1

11^2 = 121

111^2 = 12321

1111^2 = 1234321

11111^2 = 123454321
<?php

for($s=1;$s<=100000;$s=($s*10)+1) 

{

    echo $s*$s.'</br>';

}
?>

using php you can create output in this way too.


<?php

$s=1;$i=1;$j=1;$m=1;$n=1;

echo $s.'</br>';

for($s=2;$s<=5;$s++)

{

    $out=$m.$s.$n;

    echo $out.'</br>';

    $m=$m.++$i;

    $n=++$j.$n;

}

?>