Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Friday, February 2, 2018

Java Script Function To Return Selected Checkbox Value

Get the selected checkbox value from the group of checkbox list in Javascript. I wrote one function to return the selected checkbox value in Javascript.

<script type='text/javascript>

// Java Script function to return the selected checkbox value
function Checkbox_Selection_Value_From_Group (){
  fileid= $(\"input[name='filegroup[]']:checked\").map(function() {
            return this.value;
          }).get();
    if(fileid==''){
        alert('Select Minimum One Check Box');
        return false;
    }else{
  // You Will get comma separated value 
        // 1,2
       return 'id='+fileid;
    }
}
</script>

<input type="checkbox" id="filegroup" name="filegroup[]" value="1">
<input type="checkbox" id="filegroup" name="filegroup[]" value="2">
<input type="checkbox" id="filegroup" name="filegroup[]" value="3">
<input type="checkbox" id="filegroup" name="filegroup[]" value="4">

Share:

Password Generator In PHP

Password Generator In PHP Function . We can generate dynamic password with numeric, alphanumeric etc using php. I created dynamic_password function. It will generate and return the dynamic password. You should have to send password type, length like sha1, md5 for password type and numeric value for password length.


Here Is The Function

<?php
function dynamic_password($type='',$length=10){
  // Dynamic password function
  $chars = array_merge(range(0,9), range('a','z'), range('A','Z'));
  shuffle($chars);
  $password = implode(array_slice($chars, 0, $length));
  if($type=='md5'){
   $password=md5($password);
  }else if($type=='sha1'){
   $password=sha1($password);
  }
  return $password;
}
?>
Share:

Wednesday, November 9, 2016

Access MySQL from PHP

MySQL is widely used database server for php platform. It is very easy to configure MySQL database to access it from PHP.

First we have to create new database and its tables in MySQL server. I am using PHPMyAdmin client to manage database.


Create and Configure Database

Open PHPMyAdmin and click Database tab. It will ask to create new database. The screenshot is,



After creating, select your database from left panel ad create tables.


This code shows how to configure database. It requires host name, database name, database username, database password.

<?php
// to be replaced with your own information
$conn
= mysqli_connect(localhost,"root","admin","animals");
?>
Now we are ready to perform the following CRUD operations with our new databar.
  1. Create New Record
  2. Read Data from Table
  3. Update Record
  4. Delete Record

Create New Record

INSERT query is used to add new record. The syntax is,

INSERT INTO table_name VALUES (value1, value2, value3,...)
The following code is used to create new row into the database table.
<?php
//connect mysql
...
mysqli_query
($conn,"INSERT INTO animals (animal_name, animal_color) VALUES ('Elephant', 'Grey')");
mysqli_close
($conn);
?>
In this code, the values of the column is enclosed with single quotes, since values are string data type. mysql_query() function is used to execute the query.

Read Data from Table

SELECT query is used to read database table rows and the syntax is,

SELECT column FROM table_name
We can also select one or more columns separated by commas (column1,column2…). If we want to select the entire row, then * will be used. That is,

SELECT * FROM table_name
The following code is used to select list of rows from animals table.
<?php
$result
= mysqli_query($conn,"SELECT * FROM animals");
while($row=mysqli_fetch_assoc($result)) {
$tblEntries
[] = $row;
}
mysqli_close
($conn);
?>
Code will return list of animal name and it’s color in the form of associative array.
We can read data with some conditions by using WHERE clause. If we want to pick animals in gery color, then the code is,

<?php
SELECT
* FROM animals WHERE animal_color='Grey';
?>

Updating the selected row

We can edit any record using UPDATE query. The syntax is,
UPDATE table_name SET column=value WHERE someother_column=someother_value
The following code is used to update record with WHERE condition.
<?php
mysqli_query
($conn,"UPDATE animals SET animal_name='Rat' WHERE animal_name='Grey'");
mysqli_close
($conn);
?>

Deleting the selected row

Code show the syntax to the DELETE query.

DELETE FROM table_name WHERE column = value
This code will remove database records which contains animal_color = “grey”
<?php
mysqli_query
($con,"DELETE FROM animals WHERE animal_color='Grey'");
mysqli_close
($conn);
?>



Share:

Friday, April 24, 2015

15 Best PHP Frameworks for PHP Developers

                        Currently PHP is rated as the most important and functional platform for any web developer to showcase their work. This is because it is used extensively for creating web sites. Maximum of the websites which are alive on the internet is based on PHP. A good PHP framework is very crucial to choose for a web developer and the frameworks aids the user to a great extent reducing the major work load.
PHP is one such language which has evolved a lot in the time and has become a revolutionary programming language in the web world. It has now become a well-developed language with a wide collection of libraries. Here in this article we will be presenting you with the best PHP framework which are available absolutely free of cost in the market. The list has been made with extra care and is according to professional recommendation and expert advice.

15 Best PHP Frameworks for PHP Developers:

silex
This is a micro framework and is mostly used for designing basic single file apps. It has a wonderful interface and is extensible.
agavi
This is a scalable and powerful PHP5 framework and it also follows the MVC model. It emphasizes on the sustainable quality and you can write code and view the output also.
nette
This is one of the most popular frameworks and is also considered as the safest one. It has got some really cool debugging tools.
flow
This software makes a programmer focussed and the experience of programming with this framework is amazing. This gives you a faster reply, and the services are good in his software.
Simple MVC Framework
This is best for beginners and is easy to learn with this application and it also covers My SQL also.
pop php
This is a simple but strong framework and it supports PHP 5.3+ and is extremely light weight and still has got an amazing set of different functions.
PHPixie
This is again light weight software but is very quick and serves as a foundation for development of any web site.
Medoo
This is the lightest of all the PHP framework and is a micro framework. This is compatible with SQL also.
Flight
This extensive micro framework and is faster than others and allows you to develop a site quickly and with lesser work to handle.
Fuel php
Slim
This framework is designed to be a light weight and slim. It is simple and quite easy to use and has several features like template rendering, powerful router, HTTP caching and many more.
Kohana
This is an elegant framework and mostly used by professionals and allows faster development.
Zend
This is one of the most suitable frameworks for modern web development techniques. The framework has a simple design and has user friendly interface.
Aura
This feature high quality standard and well tested web applications this framework has a wonderful interface.
Cake php
This is one such framework which has been successful to help the web developer to develop a web site. The main advantage is it is new and has a faster response.
Share:

Popular Posts

Blog Archive