send multi checkbox php mysql

How can I change checkbox name to unique then I can handle it to insert to database and also when I click bottom Checkall it will check all box
<?php require_once('Connections/Thaymay.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_Thaymay, $Thaymay);
$query_RsActivitynoteMem = "Select an.id,   m1.Sname,   m1.Ssurname,   an.idactivity,   m2.Sname AS kname From activitynote an Join   member m1 On an.idmemberref = m1.idmember Join   member m2 On an.manaferid = m2.idmember Order By an.id    ";
$RsActivitynoteMem = mysql_query($query_RsActivitynoteMem, $Thaymay) or die(mysql_error());
$row_RsActivitynoteMem = mysql_fetch_assoc($RsActivitynoteMem);
$totalRows_RsActivitynoteMem = mysql_num_rows($RsActivitynoteMem);
?>
<!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=utf-8" />
<title>¿¿¿¿¿¿¿</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- 	
// by Nannette Thacker
// http://www.shiningstar.net
// This script checks and unchecks boxes on a form
// Checks and unchecks unlimited number in the group...
// Pass the Checkbox group name...
// call buttons as so:
// <input type=button name="CheckAll"   value="Check All"
	//onClick="checkAll(document.myform.list)">
// <input type=button name="UnCheckAll" value="Uncheck All"
	//onClick="uncheckAll(document.myform.list)">
// -->

<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}
//  End -->
</script>


</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="627" border="1">
    <tr>
      <td width="20">&nbsp;</td>
      <td width="198">&nbsp;</td>
      <td width="20">&nbsp;</td>
      <td width="179">&nbsp;</td>
      <td width="4">&nbsp;</td>
    </tr>
    <?php do { ?>
      <tr>
        <td><input name="checkbox" type="checkbox" id="<?php echo $row_RsActivitynoteMem['id']; ?>" value="<?php echo $row_RsActivitynoteMem['id']; ?>" />
        <label for="checkbox"></label></td>
        <td><?php echo $row_RsActivitynoteMem['Sname']; ?> <?php echo $row_RsActivitynoteMem['Ssurname']; ?></td>
        <td width="20"><?php echo $row_RsActivitynoteMem['idactivity']; ?></td>
        <td><?php echo $row_RsActivitynoteMem['kname']; ?></td>
        <td>&nbsp;</td>
      </tr>
      <?php } while ($row_RsActivitynoteMem = mysql_fetch_assoc($RsActivitynoteMem)); ?>
<tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td width="20">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <input type="button" name="CheckAll" value="Check All"
onClick="checkAll(document.form1.checkbox)">
<input type="button" name="UnCheckAll" value="Uncheck All"
onClick="uncheckAll(document.form1.checkbox)">
<br>

</form>
</body>
</html>
<?php
mysql_free_result($RsActivitynoteMem);
?>

Open in new window

teeraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AverittegCommented:
You can use jquery which can search the entire form and check all of the checkboxes it finds.

Just include this to pull in the jquery library:
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" ></script>

Add the "checkbox" class to each input checkbox.

And then to search through the form you have above:
<script language="javascript">
function checkAll()
{
      $("#form1 .checkbox").each( function() {
                        $(this).attr("checked",status);
      })
}

function uncheckAll()
{
      $("#form1 .checkbox").each( function() {
                        $(this).removeAttr("checked");
      })
}

This will work for all inputs in your form.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AverittegCommented:
An option you can do for the unique id number, you can select the record ID to put in as the checkbox ID. I see you are using an [id] as it is, but it will only work if it's unique else one box checked could result in multiple findings when searched via javascript. This will give you a way to localize each selection and know which options you're working with.
To cycle through the form to find out which id or records you're dealing with, you could use a similar fashion (.each()) in jquery and build your responses to pass over to your php server.
0
Ray PaseurCommented:
@teera, it looks like you are trying to learn PHP programming by reading DreamWeaver code.  That is like looking at an apple pie and hoping it will teach you how to cook.  Instead, drop what you're doing and get this excellent little book.  It is very readable with great examples.  Now in its fourth printing, it has been a permanent part of my professional library since Edition One.
http://www.sitepoint.com/books/phpmysql4/

This article will answer some of your questions about checkboxes...
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_5450-Common-Sense-Examples-Using-Checkboxes-with-HTML-JavaScript-and-PHP.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.