Monday, 14 May 2018

how to display multiple checkbox value from database in php

01:49

Step 1:  

SQL>
create table  userrecord (
id int primary key ,
name   varchar(200)
);


Step 2: write code for checkbox.php file:

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ankit";


// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$conn)
{
    die("Connection failed: " . mysqli_connect_error());
}

$sql="select * from userrecord";

$result=mysqli_query($conn,$sql);
while ($row=mysqli_fetch_array($result))
{

echo '<form action="select.php" method="post">

<input type="checkbox" name="check_list[]" value="'.$row['id'].'"><label> "'.$row['name'].'"</label><br/>';



}
echo '<input type="submit" name="submit" value="Submit"/>
</form>';

?>


Step 3: write code for   select.php  file:

<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ankit";


// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);

if(isset($_POST['submit'])){//to run PHP script on submit


if(!empty($_POST['check_list'])){




$data=implode(',',$_POST['check_list']);

echo $sql="select  *  from  userrecord  where  id  IN($data)";

$result=mysqli_query($conn,$sql);

while($row=mysqli_fetch_array($result))
{
echo "id=".$row['id'];
echo "name=".$row['name'];

}



// Loop to store and display values of individual checked checkbox.

}


}
?>

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

10 comments:

  1. Thanks For Sharing. It IS very helpful For Everyone ....
    If You Are Looking Best PHP training in chandigarh click here

    ReplyDelete
  2. Having trouble in Hire Php Web Developer who is reliable and experienced enough to implement the functionality and design you need? Reach out to us we have a team of developers, designers and seo experts that fulfill your dreams. we provide you Custom PHP Software Development USA, PHP Application Development India, Custom Php Software Solutions UK. Our services will be on budget of clients. We provide 100% quality assurance and dedicated to meet deadlines of the project.

    ReplyDelete
  3. Awesome blog. It was very informative. I would like to appreciate you. Keep updated like this best sap simple finance online training institute in hyderabad

    ReplyDelete
  4. This site is help full for every person and easily get money through bitcoin atm card .please visit this site for bitcoin atm card ranking.you can change any money into another currency in any where in the world.

    ReplyDelete
  5. In order to stay connected to the world around you, mobiles were invented and to use it you need to keep recharging it with balance. The basic concept of top up phone with bitcoin money is quite different from the paper money.

    ReplyDelete
  6. Shahni Digital Media provides complete digital marketing solutions to your business. e.g. ppc, social media marketing, web designing & development. Hire us to grow up your business high.

    Digital Marketing Company Bhopal
    Website Designing Company Bhopal
    SEO Company in Bhopal
    ORM Company India

    ReplyDelete
  7. Here you will find permanent seo solutions to your web project, You can save cost to find more customers online with organic search engine marketing techniques.

    ReplyDelete

PHP Training Mumbai, PHP MySQL Training Mumbai, PHP Course Mumbai, PHP Institute Mumbai

 

© 2013 PHP TRAINING IN MUMBAI BY OM SIR . All rights resevered. Designed by OM SIR

Back To Top