jasonc Posted October 7, 2021 Share Posted October 7, 2021 I have not used radio buttons but a long time. I wish to have an approve page show the images with keep or delete radio buttons underneath. There would be a few images showing at any one time waiting to be checked. I do not need a default selection for any as they admins can leave them and check again another time. <div class="floatLeft"> <img class="maxwidth" src="uploads/S<?php echo($result['img_name']); ?>"> </div> <div class="floatLeft"> <strong>Username:</strong><?php echo(htmlentities($result['user_name'])); ?></div><br> <div class="floatLeft"> <strong>Description:</strong> <?php echo($result['description']); ?></div><br> <div class="floatLeft"> <?php echo($result['created']); ?></div><br> <div class="clearFloat"></div> <div class="floatLeft"><input type="radio" name="list[]" value="<?php echo($result['id']); ?>">Approve</div> <div class="floatLeft"><input type="radio" name="del[]" value="<?php echo($result['id']); ?>">Delete</div> <div class="clearFloat"></div> The radio buttons is where I am having issues. They work but not as needed as I am able to select both delete and approve for only one. Looking to have it grouped by photo. I am not sure how I should group each photo seperately. Quote Link to comment https://forums.phpfreaks.com/topic/313894-seperate-grouped-radio-button-for-each-photo-keepdelete-options/ Share on other sites More sharing options...
Solution Barand Posted October 7, 2021 Solution Share Posted October 7, 2021 Think of radio buttons as menu options. They need the same name (so the browser knows they are part of the same menu) but different values that the user selects. Use the id (image id I presume) as part of the name to group them <input type="radio" name="action[<?=$result['id']?>]" value="A"> Approve <input type="radio" name="action[<?=$result['id']?>]" value="D"> Delete Then to process the form data foreach ($_POST['action'] as $id => $action) { if ($action == 'D') { // delete image whose ID is $id } elseif ($action == 'A') { // approve image whose ID is $id } } Quote Link to comment https://forums.phpfreaks.com/topic/313894-seperate-grouped-radio-button-for-each-photo-keepdelete-options/#findComment-1590761 Share on other sites More sharing options...
jasonc Posted October 7, 2021 Author Share Posted October 7, 2021 thank you. Quote Link to comment https://forums.phpfreaks.com/topic/313894-seperate-grouped-radio-button-for-each-photo-keepdelete-options/#findComment-1590769 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.