mbrown Posted January 28, 2009 Share Posted January 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/ Share on other sites More sharing options...
Sudden Posted January 28, 2009 Share Posted January 28, 2009 Try changing: $SQL = "DELETE FROM users WHERE ID = $id"; To: $SQL = "DELETE FROM users WHERE ID = ".$id; Not sure if thats the problem tho. Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749008 Share on other sites More sharing options...
mbrown Posted January 28, 2009 Author Share Posted January 28, 2009 the error is: You did the following: DELETE FROM users WHERE ID = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749071 Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749075 Share on other sites More sharing options...
mbrown Posted January 29, 2009 Author Share Posted January 29, 2009 you are refering to the while loop how would that be constructed now. the way i had it was the way i was taught and what not so i am little confused on how it would be set up now. Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749116 Share on other sites More sharing options...
premiso Posted January 29, 2009 Share Posted January 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749227 Share on other sites More sharing options...
mbrown Posted January 29, 2009 Author Share Posted January 29, 2009 so instead of the while it would be an if and i could get rid of the counter correct? thanks Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749641 Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 Sounds right Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-749651 Share on other sites More sharing options...
mbrown Posted January 30, 2009 Author Share Posted January 30, 2009 i want them to remove the users and display information in a table. i am still a ilttle confused on this process. Quote Link to comment https://forums.phpfreaks.com/topic/142872-variables-not-coming-over/#findComment-750606 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.