Hi Sorry to ask for help again, have tried looking last night for this little issue I want to have a link or checkbox in the backend admin that shows or hides the table record from the front end but on the backend it shows as active or deactive and is easy for the admin user to make it active and deactive by clicking a checkbox or link Or same thing but archives the table record to a archive database and then the admin user can move it back from the archive database to the main database Is either ways possible, could someone point me in the right direction or send a link that could help me get started Kind regards Ian
Uhm. Very rarely would you need to set a whole table active/not active. I can see how it would be beneficial to be able to hide certain rows in a table, and this can easily be done by adding an "active" column in the given table, and give it a boolean value type (0 or 1). The just check for this when showing records.
Sorry my mistake, I want the admin user to make active and deactive just certain rows not the whole table, sorry
Ok I have made a new column called active and gave it a boolean type of 1 for active, how do I make a radio button or checkbox that makes it active and deactive in the php page in the admin backend
Hi I have managed to get the active field entered in the mySQL database using the SET type and entering active and inactive in the values part and managed to get the two radio buttons displayed in the php page but can't work out how to make the record inactive when click the inactive radio button The php code is below if it helps $active= $row['active']; echo "<td><input type='radio' name='a'.$active . value='active'>Active <input type='radio' name='a'.$active . value='inactive'>Inactive"."</td>"; PHP:
Use values 0 and 1 in your radio buttons. Make sure both buttons have the same name. <input type="radio" name="active" value="1" /> <input type="radio" name="active" value="0" /> HTML: And in your PHP code: $db = new PDO(/* ... */); $stmt = $db->prepare(" UPDATE `table-name` SET `active` = ? WHERE [ ... ] "); $stmt->execute([(bool) $_POST['active']]); PHP: This way, when you select the 0 value radio button, it'll set it to 0, and 1 otherwise.