Jump to content

Recommended Posts

this is the code from removeusers2.php

...
	//variables
	$count = $_POST['counter'];
	$numdeleted =0;
	$num = 0;


			while ($num < $count)
	{
		//Pulling the information for if anything is checked
		$checkbox = $_POST["changed$num"];

		//If anything is checked do the following
		if($checkbox)
		{
			//pulling the variables in from the removeusers.php
			$id = $_POST["id$num"];

			//the sql query that we want to run
			$SQL = "DELETE FROM users WHERE ID = $id";
...

 

this is removeusers.php

...
	else

	{
		$Query = "SELECT * FROM users";
		$Display = mysql_query ($Query, $db) or die("<p>Unable to execute the query.</p>" . "<p>Error Code</p>" . mysql_errno($db) . ": " . mysql_error($db) . "</p>");

		$fetch = mysql_fetch_assoc($Display);

				echo "<form action='removeusers2.php' method='post'>";
				echo "<table border='5' align='center'>\n
				<tr>
					<th>Remove</th>
					<th>ID</th>
					<th>User Name</th>
					<th>Name</th>
					<th>E-mail</th>
					<th>User Group</th>

				</tr>";
			echo "\n";

			$counter = 0;

			while ($fetch)
			{
				echo "
								<tr>\n
			<td><input type = 'checkbox' name = 'changed$counter' size ='1'></td>
			<td><input type = 'text' name = 'id$count' value ='$fetch[iD]' readonly=readonly size='2'></td>\n
			<td><input type = 'text' name = 'username$count' value ='$fetch[username]' readonly=readonly size = '10'></td>\n
			<td><input type = 'text' name = 'name$count' value ='$fetch[name]' size = '30' readonly=readonly</td>\n
			<td><input type = 'text' name = 'email$count' value ='$fetch[email]' size = '30' readonly=readonly</td>\n
			<td><input type = 'text' name = 'usergroup$count' value ='$fetch[usergroup]' size = '20' readonly=readonly</td>\n";
			echo "</tr>\n";

			$fetch = mysql_fetch_assoc($Display); 
			$counter++;

			}//end of while ($fetch)
					echo "<tr><td colspan = '16'<input type = 'submit' ></td></tr>";
	echo "<input type = 'hidden' name = 'counter' value = $counter>";
	echo "</table>";
	echo "</form>";


	}//end of else
...

 

removeusers2.php is not pulling the id over correctly any idea? i am still looking this.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/
Share on other sites

Instead of doing this;

 

<input type = 'text' name = 'id$count' value ='$fetch[iD]' readonly=readonly size='2'>

 

use;

 

<input type = 'text' name = 'id[]' value ='$fetch[iD]' readonly=readonly size='2'>

 

Do that for all the fields, then you can use that to make the loop on the second page

If you setup the form as gevens suggested you could do this:

 

<?php
if (isset($_POST)) {
    if (is_array($_POST['id'])) {
          foreach ($_POST['id'] as $id) {
                 echo "ID is set to $id <br />";
          }
    }
}
?>

 

Will give you access to those items dynamically and easily.

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.