purnendu2311
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by purnendu2311
-
-
select the value from database using checkbox
« on: Today at 09:25:47 AM »
Reply with quote Modify message
Hi
Afer sending the value from database, i want to select the value from databse table. My problem is that, i want the selected value should be checked in the checkbox....How to do , Help me...
Example: I have inserted the dating, networking into database table. after that i want to dating, networking checkbox should be check after writing the select query.
<td align="left" valign="middle" bgcolor="#A3C5E0" class="blacktext">
<p>
<input name="checkbox1" type="checkbox" value="Dating" />
<span id="ctl00_ctl00_Main_ProfileEditContent_editBasicInfo_hereForCheckBoxList" class="items">
<label for="ctl00_ctl00_Main_ProfileEditContent_editBasicInfo_hereForCheckBoxList_0">Dating</label>
</span> </p>
<p>
<input type="checkbox" name="checkbox2" value="Serious
Relationships" />
<span id="ctl00_ctl00_Main_ProfileEditContent_editBasicInfo_hereForCheckBoxList" class="items">
<label for="ctl00_ctl00_Main_ProfileEditContent_editBasicInfo_hereForCheckBoxList_1">Serious
Relationships</label>
</span> </p>
<p>
<input type="checkbox" name="checkbox3" value="Friends" />
<span id="ctl00_ctl00_Main_ProfileEditContent_editBasicInfo_hereForCheckBoxList" class="items">Friends</span>
</p>
<p>
<input type="checkbox" name="checkbox4" value="Networking" />
Networking </p></td>
sql query::::::::::::::::::::::::
<?php
session_start();
include 'connection.php';
$sqry="select * from register_dtl where uname='".$_SESSION['username']."'";
$rs_s=mysql_query($sqry) or die("error:". mysql_error());
$no_of_rows_s=mysql_num_rows($rs_s);
$row_sel=mysql_fetch_assoc($rs_s);
$gender1=$row_sel['gender'];
$dob1=$row_sel['dob'];
$occupation1=$row_sel['occupation'];
$city1=$row_sel['city'];
$country1=$row_sel['country'];
$region1=$row_sel['region'];
$postal_code1=$row_sel['postal_code'];
$ethnicity1=$row_sel['ethnicity'];
$bodytype1=$row_sel['bodytype'];
$height1=$row_sel['height'];
$i_am_here_for1=$row_sel['i_am_here_for'];
if(isset($_REQUEST['occupation']) && $_REQUEST['occupation']!="")
{
$gender=$_POST['radiobutton'];
$dob=$_POST['dob'];
$occupation=$_POST['occupation'];
$city=$_POST['city'];
$country=$_POST['country_code'];
$region=$_POST['region'];
$postalcode=$_POST['postalcode'];
$ethnicity=$_POST['ethnicity'];
$bodytype=$_POST['bodytype'];
$height=$_POST['height'];
$checkbox=$_POST['checkbox'];
$checkbox1=$_POST['checkbox1'];//varible for dating
$checkbox2=$_POST['checkbox2'];//varible for serious ralationship
$checkbox3=$_POST['checkbox3'];//varible for friends
$checkbox4=$_POST['checkbox4'];//varible for networking
//$final=$checkbox1.",".$checkbox1.",".$checkbox1.",".$checkbox1;
/*
if ($checkbox1)
{
$final= $checkbox1;
}
elseif($checkbox1 && $checkbox2 )
{
$final= $checkbox1.",".$checkbox2;
}
elseif($checkbox1 && $checkbox2 )
{
}
*/
$final = ""; //initialize this variable before starting the following condition checking
if($checkbox1 != "")
$final = $final . $checkbox1;
if($checkbox2 != "" && $final != "")
$final = $final .",". $checkbox2;
else
$final = $final . $checkbox2;
if($checkbox3 != "" && $final != "")
$final = $final .",". $checkbox3;
else
$final = $final .$checkbox3;
if($checkbox4 != "" && $final != "")
$final = $final .",". $checkbox4;
else
$final = $final . $checkbox4;
$qry_ins="update register_dtl set gender='$gender',dob='$dob',occupation='$occupation',city='$city',country='$country',region='$region',postal_code='$postalcode',ethnicity='$ethnicity',bodytype= '$bodytype',height='$height',i_am_here_for='$final' where uname='".$_SESSION['username']."'";
$rs_ins=mysql_query($qry_ins) or die("error:". mysql_error());
}
Thanks & regards
Ranjan
Thanks Edit/Delete Message
-
Hello everybody,
This is my table structure. once i select the prod_nonexclusive price or prod_nonexclusive price using radio button as prod_nonexclusive or prod_exclusive
the corresponding price should come in text box.
product CREATE TABLE `product` (
`sno` int(11) NOT NULL auto_increment,
`prod_id` varchar(20) NOT NULL default '',
`prod_desc` text NOT NULL,
`prod_type` varchar(20) NOT NULL default '',
`prod_nonexclusive` double(5,0) default NULL,
`prod_exclusive` double(5,0) NOT NULL default '0',
`prod_colour` varchar(20) NOT NULL default '',
`prod_source` varchar(50) NOT NULL default '',
`prod_date` date NOT NULL default '0000-00-00',
`image1_small` longblob,
`image1_big` longblob,
`image1_small_type` varchar(20) default NULL,
`image1_big_type` varchar(20) default NULL,
`image1_prod_id` varchar(20) NOT NULL default '',
`image2_small` longblob,
`image2_big` longblob,
`image2_small_type` varchar(20) default NULL,
`image2_big_type` varchar(20) default NULL,
`image2_prod_id` varchar(20) NOT NULL default '',
`image3_small` longblob,
`image3_big` longblob,
`image3_small_type` varchar(20) default NULL,
`image3_big_type` varchar(20) default NULL,
`image3_prod_id` varchar(20) NOT NULL default '',
`image4_small` longblob,
`image4_big` longblob,
`image4_small_type` varchar(20) default NULL,
`image4_big_type` varchar(20) default NULL,
`image4_prod_id` varchar(20) NOT NULL default '',
PRIMARY KEY (`prod_id`),
UNIQUE KEY `sno` (`sno`),
KEY `prod_colour` (`prod_colour`),
CONSTRAINT `product_ibfk_1` FOREIGN KEY (`prod_colour`) REFERENCES `category` (`cat_name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Pleaze give me solution
Thanking you sir
puru
select the value from database using checkbox
in PHP Coding Help
Posted
Hi
That is currect sir, but i want to integrate with checkbox. plz give the idea.
Regards
Ranjan