Tuesday, July 11, 2017

LEARNING IN DATA SCIENCE: MODELS, ALGORITHMS AND TOOLS

LEARNING IN DATA SCIENCE: MODELS, ALGORITHMS AND TOOLS

Goal: The SEAS is delighted to announce an intensive school on Pattern Recognition. This school blends theoretical and practical aspects of Data science with focus on models, tools and techniques in data science illustrated through problems in pattern matching and pattern recognition with applications in Computer Science, Bioinformatics/Computational Biology and Image Processing.
This school is led by experts from both industry and academia and will be an immersive experience in theoretical and practical aspects of Data science for advanced UG/PG students and faculty members in Computer Science / Mathematics. This school will be an opportunity for prospective researchers to get a rigorous introduction into the fast emerging field of Data Science.


Call for participation in LEARNING IN DATA SCIENCE: MODELS, ALGORITHMS AND TOOLS
Details at https://sites.google.com/view/seasschool2017

Monday, July 10, 2017

Connecting PHP with MySQL

Connecting PHP with MySQL

Content

* Connectivity
* Selecting Database
* Insert, Update and Delete
* Select data from database
* Sample Application

Connectivity

* PHP provides several predefined functions to access MySQL, but before accessing MySQL, application need to connect MySQL as a user (similar to login from MySQL client)
* To establish connection between PHP and MySQL, PHP provides fine tuned methods like mysqli_connect().

mysqli_connect()

* Following is the format of mysqli_connection function
mysqli_connect(host,username,password,dbname);
* host: host ip address of database server, in our case it is localhost 
* username: Name of the MySQL user
* password: Password of the user
* dbname: Database name (optional)
Example
<?php 
     $con=mysqli_connect('localhost','root');
    if(!$con)
  echo "Connection failed";
    else
  echo "Connection done";
?> 

mysqli_close()

* This method is used to disconnect PHP with MySQL, similar to logout.

mysqli_close($con); 

Example

<?php 
$con=mysqli_connect('localhost','root');
     if(!$con)
  echo "Connection failed";
     else
  echo "Connection done";
/* do needful database operations here */
    mysqli_close($con); 
?>

Selecting Database

* We can select database after getting connection, using mysqli_select_db() method
mysqli_select_db($con,$databsename);

Insert, Update and Delete

* We can insert, update or delete data using mysqli_query() method. 
mysqli_query($con,$query);
* $query is query string, it can be any insert, update or delete sql statement.

Select data

* Selecting data is somewhat requires more handling, as the result of execution of select query, we may get several rows of a table.

$result = mysqli_query($con,$query);

* mysqli_query() method returns extracted data as two dimensional associative array.
$row=mysqli_fetch_array($result);

* We can fetch first row as an array of values using method mysqli_fetch_array()

* you can also count number of rows using mysqli_num_rows() method
$num=mysqli_num_rows($result);

Sample Application

* Application gives interfaces to the user to manage book records. The following functionalities must be provided:
 - Insertion of new book record
 - Deletion of record
 - Updation of record
 - View all records
 - Search book records

* First of all create a database 'library'.
* Create a table 'book' in the 'library' database.

* Columns: 
 - bookid int(5) AUTO_INCREMENT PK
 - title varchar(255)
 - price float(6,2)

* Define following php files:
 - home.php
 - insert.php
 - delete.php
 - update.php
 - bookfun.php

home.php

<?php include('bookfun.php'); ?>
<html>
 <head>
  <title> Book Store Management</title>
  <style type="text/css">
   #buttons
   {
     margin-left:50px;
     width:50%;
     border:2px solid silver;
   }
   #activityarea
   {
     margin-left:50px;
     width:50%;
     border:2px solid silver;
     height:50%;
   }
   table {
    position:relative; 
    left:25%;
    width:300px;
   }
   #insertform { display:none;}
   #back {display:none;}
   #view,#edit,#delete {display:none;}
   #view table{ border:2px solid navy; }
   #view table th {background-color:orange;}
   #view table td {background-color:khaki;}
  </style>
  <script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript">
   $(document).ready(function(){
     $("button").click(function(){
      if($(this).html()=="Insert")
       {
          $("#insertform").show();
   $(".b1").hide();
          $("#back").show();
       } 
     
      if($(this).html()=="View")
       {
          $("#view").show();
   $(".b1").hide();
          $("#back").show();
       }

      if($(this).html()=="Edit")
       {
          $("#edit").show();
   $(".b1").hide();
          $("#back").show();
       } 
      if($(this).html()=="Delete")
       {
          $("#delete").show();
   $(".b1").hide();
          $("#back").show();
       } 
     });
     $("#back").click(function(){
          $("#insertform").hide();
          $("#view").hide();
          $("#edit").hide();
          $("#delete").hide();
   $(".b1").show();
          $("#back").hide();  
     });     
   });
  </script>
 </head>
 <body>
  <h1> Book Store Management</h1>
  <div id="buttons">
   <button class="b1">Insert</button>
   <button class="b1">View</button>
   <button class="b1">Edit</button>
   <button class="b1">Delete</button>
   <button id="back">Back</button>
  </div>
  <div id="activityarea">
   <form id="insertform" action="insert.php" method="post">
    <table>
     <tr>
 <td>Book Title</td>
 <td><input type="text" name="title"/></td>
     </tr>
     <tr>
 <td>Price</td>
 <td><input type="text" name="price"/></td>
     </tr>
     <tr>
 <td></td>
 <td><input type="submit" value="store"/></td>
     </tr>
    </table>
   </form>
   <div id="view" > <?php viewbook(); ?></div>
   <div id="edit" > <?php editbook(); ?></div>
   <div id="delete" > <?php deletebook(); ?></div>
  </div>
 </body>
</html>

insert.php

<?php
  $title=$_POST['title'];
  $price=$_POST['price'];
  $con=mysql_connect('localhost','root');
  if(!$con)
   echo "Could not connect";
  mysql_select_db("lms",$con);
  $q="insert into book (title,price) values ('$title',$price)";
  mysql_query($q);
  mysql_close($con);
  header('location:http://localhost/ex2/home.php');
?>

update.php

<?php
 /* extracting HTML form data */
 $i=1;
 while(isset($_POST["title".$i]))
 {
  $bookid[$i]=$_POST["bookid".$i];
  $title[$i]=$_POST["title".$i];
  $price[$i]=$_POST["price".$i];
  $i++;
 }
 $length=$i-1;
/* Establishing Connection */
   $con=mysql_connect('localhost','root');
   if(!$con)
    echo "Could not connect";
   mysql_select_db("lms",$con);
  for($i=1;$i<=$length;$i++)
  {
   $q="update book set title='"."$title[$i]"."' ,price=$price[$i] where bookid=$bookid[$i]";
   mysql_query($q);
  }
  mysql_close($con);
  header('location:http://localhost/ex2/home.php');
?>

delete.php

<?php
 /* extracting HTML form data */
 $i=1;
 $j=1;
 while(isset($_POST["title".$i]))
 {
  if(isset($_POST["cb".$i]))
  {
   $bookid[$j]=$_POST["bookid".$i];
   $title[$j]=$_POST["title".$i];
   $price[$j]=$_POST["price".$i];
   $j++;
  }
  $i++;
 }
 $length=$j-1;
/* Establishing Connection */
   $con=mysql_connect('localhost','root');
   if(!$con)
    echo "Could not connect";
   mysql_select_db("lms",$con);
  for($j=1;$j<=$length;$j++)
  {
   $q="delete from book where bookid=$bookid[$j]";
   $s= mysql_query($q);
  }
  mysql_close($con);
  header('location:http://localhost/ex2/home.php');
?>

bookfun.php

<?php
/* Function 1*/
 function viewbook()
 {
  $con=mysql_connect('localhost','root');
  if(!$con)
   echo "Could not connect";
  mysql_select_db("lms",$con);
  $q="select * from book";
  $result=mysql_query($q);
?>
 <table>
  <tr><th>Title</th><th>Price</th></tr>
<?php
  while($row=mysql_fetch_array($result))
  {
  echo "<tr><td>".$row['title']."</td><td>".$row['price']."</td></tr>";
  }
  echo "</table>";
 }
?>

<?php 
/* Function2*/
  function editbook()
  { 
   $con=mysql_connect('localhost','root');
   if(!$con)
    echo "Could not connect"; 
   mysql_select_db("lms",$con);
   $q="select * from book";
   $result=mysql_query($q);
?>
 <form action="update.php" method="post">
 <table>
  <tr><th></th><th>Title</th><th>Price</th></tr>
<?php
  $i=0;
  while($row=mysql_fetch_array($result))
  {
   $i++;
   echo "<tr><td><input type='hidden' value='".$row['bookid']."' name='bookid".$i."' /></td>";
   echo "<td><input type='text' value='".$row['title']."' name='title".$i."'/></td><td><input type='text' value='".$row['price']."' name='price".$i."' /></td></tr>";
  }
?>
 <tr><td></td><td></td><td><input type="submit" value="save" /></td></tr>
<?php  
  echo "</table></form>";    
  }
?>

<?php
  /* function 3 */
 function deletebook()
 {
   $con=mysql_connect('localhost','root');
   if(!$con)
    echo "Could not connect"; 
   mysql_select_db("lms",$con);
   $q="select * from book";
   $result=mysql_query($q);
?>
 <form action="delete.php" method="post">
 <table>
  <tr><th></th><th>Title</th><th>Price</th></tr>
<?php
  $i=0;
  while($row=mysql_fetch_array($result))
  {
   $i++;
   echo "<tr><td><input type='checkbox' name='cb".$i."' /><input type='hidden' value='".$row['bookid']."' name='bookid".$i."' /></td>";
   echo "<td><input type='text' value='".$row['title']."' name='title".$i."'/></td><td><input type='text' value='".$row['price']."' name='price".$i."' /></td></tr>";
  }
?>
 <tr><td></td><td></td><td><input type="submit" value="Delete" /></td></tr>
<?php
  echo "</table></form>";    
 }
?>

* Do not forget to include jquery.js file

<<Prev     Home     Next>>

Stocks of the week: July 10




* Stock selection will be made from NSE F&O. The levels mentioned will be of the spot market.
* The report will be released every week.
* Recommendations will be mix of Long & Short position based upon market condition.
* The minimum risk-reward ratio in the each recommendation shall be maintained at 1:1.5.
* The stock should get initiated on the first trading day of the week, or else will be taken as not Initiated.
* The position will be closed on achieving mentioned levels and rest all open positions will be closed on the last trading day of the week by 3 P.M.
* The report will be communicated through this website.

STOCK CMP ACTION SL TGT LOT SIZE MARGIN
AMARAJABAT 860.95 BUY 832 908 600 64100
BHARTIARTL 385.45 BUY 372 408 1700 81700
CANBK 340.3 BUY 330 360 3084 131000
DRREDDY 2693.75 BUY 2585 2860 200 67100
MARUTI 7454.9 BUY 7199 7900 150 140300
TATACHEM 651.8 BUY 629 689 1500 121900
VEDL 258.55 BUY 244 281 3500 114300
ONGC 160.05 SELL 166 151 3750 75400

Refers to (if any call is not initiated, entry levels for the recommendation(s) will be sent on the trading terminal(s)CMP: Current Market Price| ENT : Entry | SL: Stop Loss | TGT: Target  | ABV: Above| BLW: Below | CD: Consumer Durables |BFSI: Banking and Financial Services| FMCG: fast Moving Consumer Goods | MISC : Miscellaneous | ANCL : Ancillaries | * The mentioned levels are future levels and the stocks will be initiated during the market hours.

Sunday, July 9, 2017

SQL

SQL

Content

* Introduction to SQL
* DDL
* DML
* Creating Database
* Creating Table
* Deleting Table
* Deleting Database
* Data Types
* Inserting Data into Table
* Updating Table
* Deleting Table Data
* Selecting Table Data
* Constraints
* NOT NULL
* UNIQUE Constraint
* Primary Key
* Foreign Key
* Default Constraint
* Auto Increment

Introduction to SQL

* Most of the actions you need to perform on a database are done with SQL statements.
* Some database systems require a semicolon at the end of each SQL statement. 
* SQL is a language common to access almost all the DBMS software.
* SQL can be divided into two parts 
 - The Data Manipulation Language (DML) 
 - The Data Definition Language (DDL)

DDL

* The DDL part of SQL permits database tables to be created or deleted.
* It specify links between tables, and impose constraints between tables. 
* The most important DDL statements in SQL are:
 - CREATE DATABASE ==> creates a new database 
 - ALTER DATABASE ==> modifies a database 
 - CREATE TABLE ==> creates a new table 
 - ALTER TABLE ==> modifies a table 
 - DROP TABLE ==> deletes a table
 - DROP DATABASE ==> delete a database

DML

* The DML is Data Manipulation Language.
* It is the set of commands to manipulate application data stored in the database.
* The query and update commands form the DML part of SQL:
 - SELECT ==> extracts data from a database 
 - UPDATE ==> updates data in a database 
 - DELETE ==> deletes data from a database 
 - INSERT ==> INTOinserts new data into a database

Creating Database

* Any user of MySQL can create database, provided he has been privileged. Providing privileges will be study in later chapters
* User root is predefined user and has all the privileges
* The CREATE DATABASE statement is used to create a database.

CREATE DATABASE database_name;

* Database is a collection of tables.
Creating Table * After creating database you can create tables in it. First select a database through use command. * Following is the syntax to create table CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, .... );
Describing table
Deleting Table * Deleting table is different from deleting content of the table. * Deleting table means the whole structure is deleted, thus all data stored in the table will also be removed. * The DROP TABLE statement is used to delete a table. DROP TABLE table_name;
Deleting Database * The DROP DATABASE statement is used to delete a database. DROP DATABASE database_name;
Data Types * SQL support variety of data types. Data Type ==> Description char(size) ==> Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis. Can store up to 255 characters varchar(size) ==> Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis. Can store up to 255 characters. Note: If you put a greater value than 255 it will be converted to a TEXT type TEXT==> Holds a string with a maximum length of 65,535 characters MEDIUMTEXT==> Holds a string with a maximum length of 16,777,215 characters LONGTEXT ==> Holds a string with a maximum length of 4,294,967,295 characters Data Type ==> Description enum(x,y,z) ==> Let you enter a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted int(size) ==> -2147483648 to 2147483647 normal. 0 to 4294967295 UNSIGNED. The maximum number of digits may be specified in parenthesis float(size,d)==> The maximum number of digits may be specified in the size parameter. The maximum number of digits to the right of the decimal point is specified in the d parameter. It occupies 4 bytes. double(size,d)==> A large number with a floating decimal point. The maximum number of digits may be specified in the size parameter. The maximum number of digits to the right of the decimal point is specified in the d parameter. It occupies 8 bytes. Data Type ==> Description date ==> A date. Format: YYYY-MM-DD. The supported range is from '1000-01-01' to '9999-12-31' time ==> A time. Format: HH:MM:SS The supported range is from '-838:59:59' to '838:59:59' bigint(size)==>  The signed range is -9223372036854775808 to 9223372036854775807.  mediumint(size)==> The signed range is -8388608 to 8388607. Inserting Data into table * The INSERT INTO statement is used to insert a new row in a table INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...);
Updating table * The UPDATE statement is used to update existing records in a table. UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value;
Deleting Table data * The DELETE statement is used to delete rows in a table. DELETE FROM table_name WHERE some_column=some_value; Selecting data from table(s) * The SELECT statement is used to select data from a database. SELECT column_name(s) FROM table_name; * Above SELECT command is to fetch all the rows from the table with selected set of columns. * SELECT command can also be used to retrieve all the rows from the table with all its columns. In such case write asterisk (*) in the place of column names SELECT * FROM table_name; * The WHERE clause is used to extract only those records that fulfill a specified criterion. SELECT column_name(s) FROM table_name WHERE column_name operator value; Constraints * Constraints are used to limit the type of data that can go into a table * Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement). * Following are the constraints: - NOT NULL - UNIQUE - PRIMARY KEY - FOREIGN KEY - DEFAULT NOT NULL * The NOT NULL constraint enforces a column to NOT accept NULL values. * The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field. * You can define any of the column NOT NULL as mentioned in the following syntax CREATE TABLE table_name ( column_name1 data_type NOT NULL, column_name2 data_type NOT NULL, column_name3 data_type, .... ); UNIQUE Constraint * The UNIQUE constraint uniquely identifies each record in a database table. * The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns * Note that you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table. Example CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), UNIQUE (P_Id) ); * You can apply Unique constraint even after creating table using alter command ALTER TABLE Persons ADD UNIQUE (P_Id); Primary Key * The PRIMARY KEY constraint uniquely identifies each record in a database table. * A primary key column cannot contain NULL values. * Primary keys must contain unique values. * Each table should have a primary key, and each table can have only ONE primary key Example CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) ); * You can define primary key even after creating table using alter command ALTER TABLE Persons ADD PRIMARY KEY (P_Id); Foreign Key * A FOREIGN KEY in one table points to a PRIMARY KEY in another table. Example CREATE TABLE Orders ( O_Id int NOT NULL, OrderNo int NOT NULL, P_Id int, PRIMARY KEY (O_Id), FOREIGN KEY (P_Id) REFERENCES Persons(P_Id) ); * Foreign key may repeat but value must exist in the master table where it is a primary key. * You can add foreign key constraint even after creating the table using alter command ALTER TABLE Orders ADD FOREIGN KEY (P_Id) REFERENCES Persons(P_Id); Default Constraint * The DEFAULT constraint is used to insert a default value into a column. * The default value will be added to all new records, if no other value is specified. Example CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) DEFAULT 'Bhopal' ); * You can set default constraint even after creating the table ALTER TABLE Persons ALTER City SET DEFAULT 'Bhopal'; Auto Increment * Very often we would like the value of the primary key field to be created automatically every time a new record is inserted. Example CREATE TABLE Persons ( P_Id int NOT NULL AUTO_INCREMENT, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) ); <<Prev     Home     Next>>

Saturday, July 8, 2017

PHP Control Instruction

PHP Control Instruction

Content

* Conditional Statement
* Loop

Conditional Statements

* Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this
* we have the following conditional statements:

 - if statement - executes some code only if a specified condition is true
 - if...else statement - executes some code if a condition is true and another code if the condition is false
 - if...elseif....else statement - selects one of several blocks of code to be executed
 - switch statement - selects one of many blocks of code to be executed

if statement

if(some condition)
{
 /* code to be executed if condition is true */
}

Example

<html>
<body>
<?php
$t=date("H");
if ($t<"12"&&$t>"5") {
   echo "Good Morning!";
}
?>
</body>
</html>

if-else statement

if(some condition)
{
/* code to be executed if condition is true */
}
else
{
/* code to be executed if condition is false */
}

Example

<html>
<body>
<?php
$x=25;
if ($x%2==0) {
   echo "Even Number";
}
else{
   echo "Odd Number";
}
?>
</body>
</html>

if-else-if….else statement

if(some condition){
/* code to be executed if condition is true */
} else if (some condition){
/* code to be executed if condition is true */
}else if(some condition){
/* code to be executed if condition is true */
}
else {
/* code to be executed if condition is false */
}

Example

<html>
<body>
<?php
$t=date("H");
if ($t<"12") {
   echo "Good Morning";
}else if($t<"17"){
   echo "Good After Noon";
} else if($t<"10"){
   echo "Good After Noon";
}else{
   echo "Good Night";
}
?> 
</body>
</html>

switch statement

switch(n)
{
 case label1:
/* code to be executed if n==label1 */
case label2:
/* code to be executed if n==label2 */
case label3:
/* code to be executed if n==label3 */
case label4:
/* code to be executed if n==label4 */
....
default:
/* code to be executed if n is different from all labels */
}

Example

<html>
<body>
<?php
$country="INDIA";
switch($country){
case "INDIA":
echo "Rupee";
break;
case "USA":
echo "Dollar";
break;
case "JAPAN":
echo "Yen";
break;
case "ENGLAND":
echo "Pound";
break;
default:
 echo "No Currency";
}
?>
</body>
</html>

Loop

* Sometimes, you want the same block of code to run over and over again, we can use loops to perform a task like this
* In PHP, we have the following looping statements:
 - while
 - do while
 - for
 - foreach

while statement

* The while loop executes a block of code as long as the specified condition is true

while(condition)
{
/*Code to be executed*/
}

Example

<html>
<body>
<?php
$x=1;
while($x<=10){
echo $x;
$x++;
}
?>
</body>
</html>

do while statement

* The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true

do
{
/*Code to be executed*/
} while(condition);

Example

<html>
<body>
<?php
$x=1;
do
{
echo $x;
$x++;
} while($x<=10);
?>
</body>
</html>

* Notice that in a do while loop the condition is tested AFTER executing the statements within the loop. This means that the do while loop would execute its statements at least once, even if the condition fails the first time.
for  statement
* The for loop is used when you know in advance how many times the script should run.

for(initialization; condition; flow)
{
/*Code to be executed*/
}

* Initialization is assigning initial value to the counter variable. Condition is any expression which will be evaluated as true of false. Flow is any change in counter variable so that loop reaches to its termination.

Example

<html>
<body>
<?php
for($x=1;$x<=10;$x++)
{
echo $x;
}
?>
</body>
</html>



Note: foreach loop will be covered with Arrays.

<<Prev     Home     Next>>

Friday, July 7, 2017

PHP Basics

PHP-MySQL

PHP Basics

Content

* Introduction to PHP 
* Installation
* PHP Syntax
* Saving and Executing PHP page
* Comments
* Variables
* Operators

Introduction to PHP

* PHP is server side scripting language
* Earlier it was Personal Home Page.
* Now a days it is PHP: Hypertext Preprocessor
* PHP is a powerful tool for making dynamic and interactive web pages.
* It was created in 1994 by Rasmus Lerdorf 
* PHP is a language for creating interactive web sites and is used on over 3.3 million web sites around the world. 
* PHP files can contain text, HTML tags and scripts 
* PHP files are returned to the browser as plain HTML. 
* PHP files have a file extension of ".php" 
* PHP can run on different platforms (windows, Linux, Unix, etc)
* PHP is compatible with almost all servers used today (Apache, IIS, etc.)
 
Installation

* You have to install three things
 - PHP
 - MySQL 
 - Apache Server
* Another Option is to install WAMP( W: Windows A:  Apache M: MySQL P: PHP )
* Download WAMP from www.wampserver.com
* WAMP is Windows Apache MySQL PHP

PHP Syntax

* A PHP scripting block always starts with 
* A PHP scripting block can be placed anywhere in the document. 
* A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
* The PHP script is executed on the server, and the plain HTML result is sent back to the browser.
* Each code line in PHP must end with a semicolon.
* There are two basic statements to output text with PHP: echo and print.
* The file must have a .php extension. 
* If the file has a .html extension, the PHP code will not be executed. 
* Whenever we create a new PHP page, we need to save it in our web servers root directory.
* For WAMP it is a folder called  www folder and is usually at this location on our hard drive:
c:\wamp\www

Saving and Executing PHP page

<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo "Welcome To PHP";
?>
</body>
</html>

1.Save the previous page by the name "demo.php" in the www folder of wamp.
2.Open the browser.
3.Type the url : " http://localhost/demo.php"
Comments
* Comments:  Comments are place in the same fashion as we do in C or C++. You can use single line comment by using //. And multi-line comment using /*...*/
Variables
* Variables are used to store constants 
* These constants could be strings, numbers or arrays. 
* When a variable is declared, it can be used over and over again in your script. 
* All variables in PHP start with a $ sign symbol


* In PHP, the variable is declared automatically when you use it.
* A variable name must start with an alphabet or an underscore "_"
* A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
* A variable name should not contain spaces. 
* In PHP, a variable does not need to be declared before adding a value to it. 
* PHP automatically converts the variable to the correct data type, depending on its value

Operators

Concatenation Operator
* There is only one string operator in PHP, it is the concatenation operator (.)  is used to put two string values together.


Arithmetic Operators

Operator  ==> Name  ==> Example  ==> Result
* +  ==> Addition  ==> $x + $y  ==> Sum of $x and $y
* -  ==> Subtraction  ==> $x - $y  ==> Difference of $x and $y
* *  ==> Multiplication  ==> $x * $y  ==> Product of $x and $y
* /  ==> Division  ==> $x / $y  ==> Quotient of $x and $y
* %  ==> Modulus  ==> $x % $y  ==> Remainder of $x divided by $y
* Operator  ==> Name  ==> Description
* ++$x  ==> Pre-increment  ==> Increments $x by one, then returns $x
* $x++  ==> Post-increment  ==> Returns $x, then increments $x by one
* --$x  ==> Pre-decrement  ==> Decrements $x by one, then returns $x
* $x--  ==> Post-decrement  ==> Returns $x, then decrements $x by one


Assignment Operators

Assignment  ==> Same as...  ==> Description
* x = y  ==> x = y  ==> The left operand gets set to the value of the expression on the right
* x += y  ==> x = x + y  ==> Addition
* x -= y  ==> x = x – y  ==> Subtraction
* x *= y  ==> x = x * y  ==> Multiplication
* x /= y  ==> x = x / y  ==> Division
* x %= y  ==> x = x % y  ==> Modulus

Relational Operators

Operator  ==> Name  ==> Example  ==> Result
* ==  ==> Equal  ==> $x == $y  ==> True if $x is equal to $y
* ===  ==> Identical  ==> $x === $y  ==> True if $x is equal to $y, and they are of the same type
* !=  ==> Not equal  ==> $x != $y  ==> True if $x is not equal to $y
* <>  ==> Not equal  ==> $x <> $y  ==> True if $x is not equal to $y
* !==  ==> Not identical  ==> $x !== $y  ==> True if $x is not equal to $y, or they are not of the same type
* >  ==> Greater than  ==> $x > $y  ==> True if $x is greater than $y
* <  ==> Less than  ==> $x < $y  ==> True if $x is less than $y
* >=  ==> Greater than or equal to  ==> $x >= $y  ==> True if $x is greater than or equal to $y
* <=  ==> Less than or equal to  ==> $x <= $y  ==> True if $x is less than or equal to $y

Logical Operators

Operator  ==> Name  ==> Example  ==> Result
* and  ==> And  ==> $x and $y  ==> True if both $x and $y are true
* or  ==> Or  ==> $x or $y  ==> True if either $x or $y is true
* xor  ==> Xor  ==> $x xor $y  ==> True if either $x or $y is true, but not both
* &&  ==> And  ==> $x && $y  ==> True if both $x and $y are true
* ||  ==> Or  ==> $x || $y  ==> True if either $x or $y is true
* !  ==> Not  ==> !$x  ==> True if $x is not true


<<Prev     Home     Next>>

Thursday, July 6, 2017

Menu Designing

Menu Designing

Content
* Menu
* Sample Menu Designing Example

Menu

* Menu in any web application facilitate easy navigation to the user
* Content of your web application is categorized and displayed in different pages. To access these pages you design menu as links to web pages.
* Menu can be designed in many ways, in fact it is a matter of designing and innovation.
* Fancy menu may use HTML, CSS and javascript.
* Go through the following examples and understand the basics. 
 
Sample Menu Designing Example

Example 1

menu.html

<html>
 <head>
  <link rel="stylesheet" href="menu.css"/>
  <script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript">
   $(document).ready(function(){
    $("ul li").hover(
     function(){
         $("ul",this).css("display","block");
         $("a",this).css("color","red");
   $("a",this).css("background-color","lightblue");
  $("ul li a",this).css("background-color","white");
         $("ul li a",this).css("color","#777");
              },
     function(){
       $("ul",this).css("display","none");
       $("a",this).css("color","#777");
       $("a",this).css("background-color","white");
    });
   });
  </script>
 </head>
 <body>
  <ul id="ul1"> 
    <li class="li1"><a class="a1" href="#">Home</a></li> 
    <li class="li1"><a class="a1" href="#">Courses</a> 
      <ul> 
        <li><a class="a2" href="#">C/C++</a></li> 
        <li><a class="a2" href="#">PHP</a></li> 
        <li><a class="a2" href="#">Java</a></li> 
      </ul> 
    </li> 
    <li class="li1"><a class="a1" href="#">Services</a> 
      <ul> 
        <li><a class="a2" href="#">Web Design</a></li> 
        <li><a class="a2" href="#">Internet Marketing</a></li> 
        <li><a class="a2" href="#">Hosting</a></li> 
        <li><a class="a2" href="#">Domain Names</a></li> 
        <li><a class="a2" href="#">Broadband</a></li> 
      </ul> 
    </li>
    <li class="li1"><a class="a1" href="#">Contact Us</a> 
      <ul> 
        <li><a class="a2" href="#">Bhopal</a></li> 
        <li><a class="a2" href="#">Indore</a></li> 
        <li><a class="a2" href="#">Bangalore</a></li> 
        <li><a class="a2" href="#">Hydrabad</a></li> 
      </ul> 
    </li> 
  </ul>
 </body>
</html>

menu.css

body
{
        background-color:lightgray;
}
#ul1,ul 
{
  position:relative;
 list-style: none;
}
#ul1 .li1
{
        display:table-cell;
        width:150px;
}
li ul li
{
 position:relative;
 left:-40;
}
ul li ul
{
 position:absolute; 
 display:none;
 border:2px solid black;
 background-color:white;
 width:110px;
}
.a1
{
 background-color: #fff;
 border: 1px solid #ccc;
}
.a2
{
 width:140;
}
ul li a 
{
 display:block;
 text-decoration: none;
 color: #777;
 padding: 5px;
 border-bottom: 0;
        margin:0;
}

Example 2

menu.html

<html>
 <head>
  <link rel="stylesheet" href="menu.css"/>
  <script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript">
   $(document).ready(function(){
    $("#ul1 li").hover(
     function(){
         $("ul",this).css("display","block");
         $("a",this).css("color","red");
   $("a",this).css("background-color","lightblue");
  $("ul li a",this).css("background-color","white");
         $("ul li a",this).css("color","#777");
              },
     function(){
       $("ul",this).css("display","none");
       $("a",this).css("color","#777");
       $("a",this).css("background-color","white");
    });
   });
  </script>
 </head>
 <body>
  <ul id="ul1"> 
    <li><a href="#">Home</a></li> 
    <li><a href="#">Courses</a> 
      <ul> 
        <li><a href="#">C/C++</a></li> 
        <li><a href="#">PHP</a></li> 
        <li><a href="#">Java</a></li> 
      </ul> 
    </li> 
    <li><a href="#">Services</a> 
      <ul> 
        <li><a href="#">Web Design</a></li> 
        <li><a href="#">Internet 
            Marketing</a></li> 
        <li><a href="#">Hosting</a></li> 
        <li><a href="#">Domain Names</a></li> 
        <li><a href="#">Broadband</a></li> 
      </ul> 
    </li>
    <li><a href="#">Contact Us</a> 
      <ul> 
        <li><a href="#">Bhopal</a></li> 
        <li><a href="#">Indore</a></li> 
        <li><a href="#">Bangalore</a></li> 
        <li><a href="#">Hydrabad</a></li> 
      </ul> 
    </li> 
  </ul>
 </body>
</html>

menu.css

body
{
        background-color:lightgray;
}
ul 
{
 margin: 0;
 padding: 0;
 list-style: none;
 width: 150px;
}
ul li 
{
 position: relative;
}
li ul 
{
 position: absolute;
 left: 149px;
 top: 0;
 display: none;
}
ul li a 
{
 display: block;
 text-decoration: none;
 color: #777;
 background: #fff;
 padding: 5px;
 border: 1px solid #ccc;
 border-bottom: 0;
}





<<Prev     Home     Next>>

Wednesday, July 5, 2017

Monthly Investment Ideas


Monthly Investment Ideas

Monthly technical report which recommends 10 stocks for long stance from the BSE-100 basket. We derive these recommendations on the basis of companies’ performance, its track record and our thorough analysis of the stocks.

STOCK SECTOR CMP ACTION AVERAGE SL TGT 1 TGT 2
ADANIPORTS INFRA 363.05 Buy 345 325 410 440
AMBUJACEM CEMENT 246.55 Buy 234 224 270 278
ASHOKLEY AUTO 93.85 Buy 88 86 101 105
AUROPHARMA PHARMA 684.6 Buy 645 625 740 780
BHARTIARTL TELECOM 379.7 Buy 365 349 410 435
ICICIBANK BFSI 290.15 Buy 278 269 320 330
ITC FMCG 323.65 Buy 307 299 348 355
JSWSTEEL METALS 203.4 Buy 196 189 217 224
M&MFIN BFSI 344.95 Buy 330 316 390 400
TITAN CD 524.45 Buy 494 470 580 605

CMP:Current Market Price | SL: Stoploss | Tgt: Target