Jump to content

Recommended Posts

hello...

 

I have a php dynamic table where the results show any outstanding channels that need to be checked off.

 

so on the php side i have created the following....

 

mysql_select_db($database_mysql, $mysql);
$query_not_checked = "SELECT DISTINCT   ref_db.name_id, ref_db.name_ch,    ref_db.tdate,    members.firstname,    tbl_requestors.req_name,    checked_id.checked,    datediff(NOW(), ref_db.tdate) AS Date_Difference FROM members    INNER JOIN ref_db ON (members.member_id = ref_db.user_id)    INNER JOIN tbl_requestors ON (ref_db.assign_id = tbl_requestors.index_id)    INNER JOIN checked_id ON (ref_db.checked_id = checked_id.index_id) WHERE checked_id.index_id LIKE 1  ";
$not_checked = mysql_query($query_not_checked, $mysql) or die(mysql_error());
$row_not_checked = mysql_fetch_assoc($not_checked);
$totalRows_not_checked = mysql_num_rows($not_checked);

<form id="form10" name="form10" method="post" action="">
  <div id="CollapsiblePanel1" class="CollapsiblePanel">
    <div class="CollapsiblePanelTab" tabindex="0">Channels Not Checked  - (<?php echo $totalRows_not_checked;?>)</div>
    <div class="CollapsiblePanelContent">
      <table width="891" border="1" cellpadding="1" cellspacing="1" class="css_refdb">
        <tr>
          <td width="175"><div align="center"><strong>Name Channel</strong></div></td>
          <td width="200"><div align="center"><strong>Date Checked</strong></div></td>
          <td width="138"><div align="center"><strong>User Name</strong></div></td>
          <td width="143"><div align="center"><strong>Requestor</strong></div></td>
          <td width="179"><div align="center"><strong>Date Difference</strong></div></td>
	  <td width="179"><div align="center"><strong>Checked</strong></div></td>
	</tr>
        <?php do { ?>
          <tr>
            <td><div align="left"><?php echo $row_not_checked['name_ch']; ?></div></td>
            <td><div align="center"><?php echo $row_not_checked['tdate']; ?></div></td>
            <td><div align="left"><?php echo $row_not_checked['firstname']; ?></div></td>
            <td><div align="left"><?php echo $row_not_checked['req_name']; ?></div></td>
            <td><div align="center"><?php echo $row_not_checked['Date_Difference']; ?></div></td>
		<td><div align="center"><input type="checkbox" id="ONOFF" name="ONOFF[]" value="<?php echo $row_not_checked['name_id']; ?>"></div></td>
          </tr>
          <?php } while ($row_not_checked = mysql_fetch_assoc($not_checked)); ?>
      </table>
  <br>
  <input type="submit" value="Submit" name="submit" id="button" />
   <br>
    </div>
  </div>
  </form>

 

 

 

Now how do I submit the checked boxes to update the mysql table using the following mysql query.... but remember users can check more than one....

 

update ref_db set checked_id = checked_id +1, tchecked = now() where name_id = CHECKEDBOX

 

 

Link to comment
https://forums.phpfreaks.com/topic/171635-solved-submitting-multiple-checkboxes/
Share on other sites

ok thats something i will look into .... but here is something that i have redeveloped... but it only submits one line and not more than one.....

 

I believe there is something missing in the last piece of code as the information gets sent through but only updates one and not two more ....

 

 

Table Information:

 

mysql_select_db($database_mysql, $mysql);
$query_not_checked = "SELECT DISTINCT   ref_db.name_id, ref_db.name_ch,    ref_db.tdate,    members.firstname,    tbl_requestors.req_name,    checked_id.checked,    datediff(NOW(), ref_db.tdate) AS Date_Difference FROM members    INNER JOIN ref_db ON (members.member_id = ref_db.user_id)    INNER JOIN tbl_requestors ON (ref_db.assign_id = tbl_requestors.index_id)    INNER JOIN checked_id ON (ref_db.checked_id = checked_id.index_id) WHERE checked_id.index_id LIKE 1  ";
$not_checked = mysql_query($query_not_checked, $mysql) or die(mysql_error());
$row_not_checked = mysql_fetch_assoc($not_checked);
$totalRows_not_checked = mysql_num_rows($not_checked);

 

 

<form id="form1" name="form1" method="post" action="<?php $_SERVER["php_SELF"];?>">
  <div id="CollapsiblePanel1" class="CollapsiblePanel">
    <div class="CollapsiblePanelTab" tabindex="0">Channels Not Checked  - (<?php echo $totalRows_not_checked;?>)</div>
    <div class="CollapsiblePanelContent">
      <table width="891" border="1" cellpadding="1" cellspacing="1" class="css_refdb">
        <tr>
          <td width="175"><div align="center"><strong>Name Channel</strong></div></td>
          <td width="125"><div align="center"><strong>Date Checked</strong></div></td>
          <td width="138"><div align="center"><strong>User Name</strong></div></td>
          <td width="143"><div align="center"><strong>Requestor</strong></div></td>
          <td width="179" class="css_refdb"><div align="center"><strong>Date Difference</strong></div></td>
          <td width="179"><div align="center"><strong>Checked</strong></div></td>
        </tr>
        <?php do { ?>
          <tr>
            <td><div align="center"><?php echo $row_not_checked['name_ch']; ?></div></td>
            <td><div align="center"><?php echo $row_not_checked['tdate']; ?></div></td>
            <td><div align="center"><?php echo $row_not_checked['firstname']; ?></div></td>
            <td><div align="center"><?php echo $row_not_checked['req_name']; ?></div></td>
            <td><div align="center"><?php echo $row_not_checked['Date_Difference']; ?></div></td>
            <td><div align="center"><input type="checkbox"  name="checked[]" value="<?php echo $row_not_checked['name_id'];?>"   /></div></td>
          </tr>
          <?php } while ($row_not_checked = mysql_fetch_assoc($not_checked)); ?>
      </table>
    <br />
    <input type="submit" value = "submit" name="submit" id="button" />
    <br />
        </div>
  </div>
</form>

 

 

<?php
$i=0;

$name_id = $_POST['checked'];

if (is_array($name_id)){

for ($i=0;$i<count($name_id);$i++)

$query_update = "UPDATE ref_db set checked_id = checked_id + 1, tchecked = now() where name_id = '$name_id[$i]'";
mysql_query($query_update);
echo $query_update;
{

}

}

?>

Sorted the problem out.... follow the steps....

 

In your form add

 

<form id="form3" name="form3" method="post" enctype="multipart/form-data" action="<?php $_SERVER["php_SELF"];?>">

 

 

and then i used

 

 

<?php
if ($_POST['checked1'])
{
foreach($_POST["checked1"] as $key => $id)
{
$query_update = ("UPDATE ref_db set checked_id = checked_id + 1, tchecked = now() where name_id = '".(int)$id."'");
mysql_query($query_update);

}
}
else

{

}

 

to call up when submitting.....

 

it worked!!

Hi

 

Might be worth using something like this to avoid doing multiple UPDATE statements.

 

<?php
if ($_POST['checked1'])
{
$query_update = ("UPDATE ref_db set checked_id = checked_id + 1, tchecked = now() where name_id IN (".implode(',',$_POST['checked1']).")";
mysql_query($query_update);
}
else
{
}
?>

 

All the best

 

Keith

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.