Jump to content

Edit and delete options


Xtremer360

Recommended Posts

Old issue of mine that I'm coming back to. My question is I'm trying to figure out how to work with the select box of options and apply button so that if delete is chosen and the user clicks on apply it performs the deletedivision inside the process page I know it deals with jquery's ajax however this part of it does not that I'm trying to get fixed because as of right now I have if (isset($_POST['deletedivision'])) and I know that's not right and I know I can't apply a name to the option tag because name isn't one of option's allowable attributes.

 

mods/divisions.php

<form action="" method="post">
			<label for="actionSelect">With selected items: </label>
			<select class="select" name="actionSelect" id="actionSelect">
				<option id="1">Edit</option>
				<option id="2">Delete</option>
			</select>
			<button class="button small-button"><strong>Apply</strong></button>
		</form>

 

<?php 
        while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) {
              echo '
              <tr>
              <td><input type=checkbox class=checkbox name=checkbox[] id=checkbox[] value="' . $row['id'] . '" /></td>
		  <td>' . $row['divisionname'] . '</td>
		  <td>' . $row['name'] . '</td>
		  <td class=last>' . $row['datecreated'] . '</td>
		  </tr>';
            }
        ?>

 

processes/divisions.php

if (isset($_POST['deletedivision'])) {
    $checkbox = $_POST['checkbox'];
    $countCheck = count($_POST['checkbox']);
    
    for($i=0;$i<$countCheck;$i++) {
   $del_id  = $checkbox[$i];
       $query = "DELETE from `divisions` where id = $del_id";
       
       mysqli_query($dbc,$query);
    }

}

Link to comment
Share on other sites

  • 4 weeks later...

Instead of recreating this topic I just bumped it up so that I can maybe get some answers for this post.

 

I have the process page finished but what I'm trying to do is when the user ticks a check box and then makes a selection of either Edit or Delete from the drop down menu it will do one of two things. If the user selected Edit then they will be taken to the edit form with the passed id value and load use that passed value to load information from the database and if the user had selected Delete from the drop down menu then it'll use well jQuery's Ajax function to handle delete the row from the db.

 

The issue I'm having is figuring out with this template is how to pass the id value up to that other form with the drop down menu.

 

129 or so line code

http://pastebin.com/bBim31RK

Link to comment
Share on other sites

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.