954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with Dynamic Checkbox

hye all, im here just want to ask for a very basic problem about checkbox. i do search but there is nothing related to my problem.

my problem is :

1 - i have a dynamic table with checkbox on each row of my table.

2 - each row has different value since it carry out from my database.

3 - i want to multiple add from the selected checkbox into the other table.

4 - thing is fine but then, there is no value carry to the database. ( i noticed that i don carry any value into it, i dont know how to do that ).

here is the sample of my code :

//<?php
while($rows=mysql_fetch_array($result)){
?>

<? echo $rows['subject_id']; ?>

<? echo $rows['subject_name']; ?>



<?php
}
?>




<?
if($add){
foreach($_POST['checkbox'] as $add_id)
{
//for($i=0;$i<$count;$i++){
$add_id = $checkbox[$i];
$sql = "INSERT INTO $tbl_name2 (subject_id, subject_name) VALUES ('$add_id', '$add_id')";
$result = mysql_query($sql);
}

// if successful redirect to user.php
if($result){
echo "";
}
}
mysql_close();
?>

thank you in advance.

bearbrick
Newbie Poster
1 post since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

Hello, first place the the insert statemen at the top of your script. use an echo in front of the insert statement to debug if the values are filled.

Olaf

olaf
Newbie Poster
10 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You