Posts

Showing posts from December, 2015

MYSQLI_ASSOC and MYSQLI_NUM

// mysqli_fetch_array($query)                          [General and simple Process] while ($row = mysqli_fetch_array($query)) {         ?>         <tr>             <td><?php echo $row['id']; ?></td>             <td><?php echo $row['name']; ?></td>             <td><?php echo $row['roll']; ?></td>             <td><?php echo $row['created_date']; ?></td>         </tr>         <?php     } // MYSQLI_ASSOC         ...

mysqli Connect, Insert and Query data

// Build Connection with database. $con = mysqli_connect("localhost","hkc","123","test_db"); // Database Connection checking with error numbers if(mysqli_connect_error()){         echo "Connection Error Number is : ".mysqli_connect_errno();     } // Specify values for enjoined fields of destination table. Type 01 : $insert = "INSERT INTO test_table(name,roll,created_date) VALUES('Hasib',4153,NOW())"; Type 02 : $insert = "INSERT INTO test_table VALUES(null,'romel',4160,NOW())"; //Built Connection and send data into fields. mysqli_query($con,$insert); // Create Query $query = mysqli_query($con,"SELECT * FROM test_table"); // To get few info by your query print_r($query) // Object oriented using this operator $query->num_rows;                                 [**n...

SQL connection and check error

Set SQL connection and check error with error numbers. <?php $con = mysqli_connect("localhost","root","","testdb"); if(mysqli_connect_errno()){     echo "Faild to connect My SQL : ".mysqli_connect_error(); } ?>

Basic difference for subtraction with two formula

 Formula 1 :                    387                    -98                   ------                   289 1st step we borrow 1/(10) from 8 and then make 7 into 17. (17-8=9). 2nd step we add borrowed 1 with 9 and again borrow 1/(10) from 2. (18-10=8). 3rd step we subtract  borrowed 1 from 3. (3-1=2). ______________________________________________________________ Formula 2 :                  387                  -98        ...

Call by reference in php OOP

<?php     class a{         public function calc(&$a,&$b){             return $a+$b;         }     }     $obj = new a();         $v1=2;         $v2=4;     echo $obj->calc($v1,$v2); ?> When you will pass value by reference then remember you must have to use '&' sing in parameter with variable as like as the example given up.

Regular Expression

1. ([a-z]+) this expression will count a word from small a to small z. Such as according to this code which is given below. <?php     $preg = "aAAAA Bbbbb bbbbb bbbbbb";     echo preg_replace("([a-z]+)", "1", $preg); ?> You will get this output '1AAAA B1 1 1'. 2. ([a-z]) this expression will count a single character from small a to small z. Such as according to this code which is given below. <?php     $preg = "aAAAA Bbbbb bbbbb bbbbbb";     echo preg_replace("([a-z])", "1", $preg); ?> You will get this output '1AAAA B1111 11111 111111'.

php preg_replace

preg_replace is a function which is use in regular expression. <?php     $preg = "aAAAA Bbbbb";     echo preg_replace("([a-z])", "1", $preg); ?> There $preg is a variable and we stored some strings in this variable. preg_replace(); function is a builtin function which has three parameters. First parameter is for regular expression condition, the second one is for required output, and the last and third parameter is to select the variable that in which variable you want to apply preg_replace() function.

PHP Public, Private, Protected

In php (object oriented programming) you can define three types of variable in class. Usually variable in class is called by operator. Three types are public,private,and protected. public : When you will define public type. You can access it anywhere. Inside of it's own class or another class or outside of the class. protected : When you will define protected type. You can access it only in class. Not only in it's own class but also it can access in another class but never outside the class protected type is accessible. private : Private is the most secure type. It is only accessible in it's own class. And not accessible neither other class nor outside of any class.

Object Oriented Programming PHP

PHP is also object oriented programming....... <?php     class abc{         function hkc(){             echo "Hasib Kamal Chowdhury";         }     }     $object = new abc;     echo $object->hkc(); ?> This is very basic example of OOP in PHP. Here, At first of all we have to create a class. In this code we created a class named 'abc' and in this class we declared a function named 'hkc()'. So, Now the question is how we will call the function hkc() from the class 'abc'. In the next step we have to create an object. $object is something like as variable where we contained the class 'abc'. Procedure shown below how to make object. $variable = new abc; This is the procedure to create object. Now we will call hkc() function from $object. The procedure of calling function from object is shown below. $o...