netman182 Posted December 14, 2009 Share Posted December 14, 2009 I am having a brain fart right now and i cant remember how to do this. if anyone could help that would be great. I have search google and this forum but have not found what i am looking for. thanks when an employee registers they must be approved by a manager to have access to the login pages. I have a table with a record called approved. It's initial value is 0. I want a query to show all that are 0. but at the same time i need to be able to click a checkbox to make the value 1. I need this to be a mass check box list. Here is an idea of the SQL: Select * from users where approved ='0' i then need to to display all the rows and fields for each user where the approved is '0' i also want to be able to update the approved with a checkbox. how possible is this for someone to give me a hand. thanks alot. Link to comment https://forums.phpfreaks.com/topic/185056-checkbox-update/ Share on other sites More sharing options...
Buddski Posted December 14, 2009 Share Posted December 14, 2009 Heres a little snippet i just wrote.. youll need to read it and change some variables and add the rest of the updating functionality etc.. <?php if (isset($_POST['approve'])) { foreach ($_POST['approve'] as $id=>$value) { } } $sql = "SELECT * FROM `users` WHERE `approved`='0'"; $sql_query = mysql_query($sql); if (mysql_num_rows($sql_query) > 0) { echo '<form action="whatever.php" method="post">'; while ($data = mysql_fetch_array($sql_query)) { echo $data['user_name'].': <input type="checkbox" name="approve['.$data['user_id'].']" value="1" />'; } echo '</form>'; } else { echo 'No Users to approve'; } ?> Link to comment https://forums.phpfreaks.com/topic/185056-checkbox-update/#findComment-976827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.