Hi........
I want to know, how to insert value from many checkbox in database (mysql) from front end (HTML form) in PHP ? Please explain with example ?
Thanks.....
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Mar 29, 2012, 1:37 PM
Try this...
Table structure
-- phpMyAdmin SQL Dump
-- version 2.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 29, 2012 at 05:17 PM
-- Server version: 5.0.45
-- PHP Version: 5.2.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `test`
--
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
CREATE TABLE `employee` (
`name` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee`
--
config.php
/* Database Connection */
$sDbHost = 'localhost';
$sDbName = 'test';
$sDbUser = 'root';
$sDbPwd = '';
$dbConn = mysql_connect ($sDbHost, $sDbUser, $sDbPwd) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($sDbName,$dbConn) or die('Cannot select database. ' . mysql_error());
?>
form.php
checkbox.php
include("config.php");
$checkbox1 = $_POST['chk1'];
if($_POST["Submit"]=="Submit")
{
for ($i=0; $i
mysql_query($query) or die(mysql_error());
}
echo "Record is inserted";
}
?>
Thanks
If this post helps you mark it as answer
Vineet Kumar SainiPosted Apr 4, 2012, 6:38 AM