Friday, July 7, 2017

PHP - Programming 2


// Check number---regular or irregular


//This is first file-------   num.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>check Numbers</title>
</head>
<body>
<form action="number.php" method="post">
Please input six number=<input type="text" id="num" name="num"/><br/>
<input type="submit" id="submit" name="submit"/>
</form>
</body>
</html>
//This is Second file------ number.php
<?php
$num=$_POST["num"];
for($i=0; $i<6; $i++)
{
if($num[$i]==($num[$i+1]-1))
{
 $flag=$flag+1;
 if($flag==5)
 {
  echo "Number is regular". "<br/>";
 }
}
else if(($num[$i]-1)==$num[$i+1])
{
    $flag1=$flag1+1;
 if($flag1==5)
 {
  echo "Number is regular". "<br/>";
 }
}
 if($flag<5 && $flag1<5)
 {
  echo "Number is irregular". "<br/>";
 }

?>

Tuesday, July 4, 2017

PHP - Programming 1



//USE OF SELECT OPTION WHICH SHOW VALUE ACCORDING DATABASE

<?php
  include('my_conn.php');
  $my_sql="SELECT *
  FROM login
  WHERE lid =1101";
  $myresult=mysql_query($my_sql);
  
  
   while($row_select=mysql_fetch_array($myresult))
  {
  
    $check=$row_select['lactive'];

  }
//$check="";
?>
<form action="" post="">
    <select  id="lactive" name="lactive">
        <?php
        if($check=="")
        {
            echo '<option  value="">Select..</option>';
            echo '<option  value="YES">YES</option>';
            echo '<option  value="NO">NO</option>';
        }
        else
        {
        if($check=='YES')
        {
                 echo '<option  value="<?=$check;?>">Yes</option>';
                 echo '<option  value="No">No</option>';
        }
        else
        {
               
                echo '<option  value="<?=$check;?>">No</option>';
                echo '<option  value="">Yes</option>';
         }
        }
         ?>
    </select>
    <input type="submit" id="submit" name="submit"/>
</form>