checkbox should be check, after fetching the value from data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
purnendu231172
Forum Newbie
Posts: 11
Joined: Mon Apr 16, 2007 6:29 am

checkbox should be check, after fetching the value from data

Post by purnendu231172 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all,

I have four check box, i want to send 1st & 4th value of the check box into database table after selecting one or more option. ie if i select the dating and Networking, the both should store into database. example: dating, Networking in table.
I am select the 1st and 4th option three comma is coming inbetween dating and friend option, but i want only one comma ie dating, Networking in table.It coming like that only .


This is the Problem::But afer sending the value from database, i want to select the value from databse table. My problem is that, i want the select value should be checked in the checkbox....How to do , Help me...

This is the code :::::::

[syntax="html"]<input type="checkbox" name="checkbox1" value="Dating" />Dating

<input type="checkbox" name="checkbox2" value="Serious Relationships" />Serious Relationships

<input type="checkbox" name="checkbox3" value="Friends" />Friends
<input type="checkbox" name="checkbox4" value="Networking" /> Networking

I am using this variable::::::::::;[/syntax]

Code: Select all

$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());
Can anyone will help me it is urgent

Thanks & Regards

Ranjan
Thanks Reply With Quote


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

So get this.. General Discussion is NOT for programming questions.
Post Reply