/    Sign up×
Community /Pin to ProfileBookmark

edit multiple checkbox(urgent)

i have a multiple checkbox of options1,options2,options3,options4.i want to do when i add options1,options2,options3 it will shows on the database.and when i will go to my edit page it will shows that the options1,options2And options3 are already checked.how can i do this?please anybody help me .my code is below
body portion
<body>
<form name=”name” method=”post” id=”f1″ action=”insertpage.php”>
<fieldset><legend align=”center”>Page Information</legend>
Page Title:<input type=”text” name=”pagetitle” />
<br />
page Description:<textarea name=”pagedescription”></textarea>
<br />
Keywords:<input type=”text” name=”keywords”><br />
Content:<textarea name=”content”></textarea><br />
<INPUT NAME=”options” TYPE=”CHECKBOX” value=”1″>
Option 1<BR>
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”2″>
Option 2<BR>
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”3″>
Option 3<BR>
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”4″>
Option 4<BR>
<input type=”submit” value=”Add” id=”f1″ name=”submit”>
</fieldset>
</form>
</body>

insert page
<?php
include ‘config.php’;
//require_once ‘includes/sessions.php’;
$pt=$_REQUEST[‘pagetitle’];
$md=$_
REQUEST[‘pagedescription’];
$mk=$_REQUEST[‘keywords’];
$mc=$_
REQUEST[‘content’];
$chk=$_REQUEST[‘options’];
$sql=”insert into `page`(`page_title`,`meta_des`,`meta_keywords`,`meta_content`,`checkbox1`)values(‘$pt’,’$md’,’$mk’,’$mc’,’$chk’)”;
$r=mysql_query($sql) or die (“Couldn’t select” . mysql_error());
?>

edit page
<?php
$id=$_REQUEST[‘id’];
$pt=$_
REQUEST[‘pagetitle’];
$md=$_REQUEST[‘pagedescription’];
$mk=$_
REQUEST[‘keywords’];
$mc=$_REQUEST[‘content’];
$chk=$_
REQUEST[‘options’];
$sql=”update `page` set `page_title`=’$pt’,`meta_des`=’$md’,`meta_keywords`=’$mk’,`meta_content`=’$mc’,`checkbox1`=’$chk’ where `page_id`=’$id'”;
$r=mysql_query($sql)or die (“Couldn’t select” . mysql_error());
header(“location:page1.php?id=<?php echo $id;?>”);
?>

<?php
session_start();
//require_once ‘includes/sessions.php’;
include ‘config.php’;
$id=$_REQUEST[‘id’];
$query=”select * from `page` where page_id=”.$id;
$result=mysql_query($query) or die (“Couldn’t select” . mysql_error());
$row=mysql_fetch_array($result);
?>
editview page
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>
<body>
<form name=”name” method=”post” id=”f1″ action=”page2.php?id=<?php echo $id;?>”>
<fieldset><legend align=”center”>Page Information</legend>
Page Title:<input type=”text” name=”pagetitle” value=”<?php echo $row[‘page_title’];?>” />
<br />
page Description:<textarea name=”pagedescription” ><?php echo $row[‘meta_des’];?></textarea>
<br />
Keywords:<input type=”text” name=”keywords” value=”<?php echo $row[‘meta_keywords’];?>”/><br />
Content:<textarea name=”content”><?php echo $row[‘meta_content’];?></textarea><br />
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”<?php echo $row[‘checkbox’];?>”>
Option 1<BR>
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”<?php echo $row[‘checkbox’];?>”>
Option 2<BR>
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”<?php echo $row[‘checkbox’];?>”>
Option 3<BR>
<INPUT NAME=”options” TYPE=”CHECKBOX” VALUE=”<?php echo $row[‘checkbox’];?>”>
Option 4<BR>
<input type=”submit” value=”Update” id=”f1″ name=”submit”>
</fieldset>
</form>
</body>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 29.2009 — &lt;INPUT NAME="options" TYPE="CHECKBOX" VALUE="&lt;?php echo $row['checkbox'];?&gt;" &lt;?php echo $checked;?&gt;"&gt;
Where $checked is string "checked" or "", depending on the value set in DB for each checkbox.
×

Success!

Help @Tiyasa09 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...