mbrown Posted February 26, 2017 Share Posted February 26, 2017 So I have following code <p>Please choose a motion to vote on. Only one motion can be voted on at a time</p> <form id="vote" action="voting.php" method="post"> <table border="1" width="100%"> <tr> <th>Select</th> <th>Motion Text</th> <th>Date Added</th> </tr> <?php include_once ('include/db-config.php'); $motions=$db_con->prepare( "select * from motions where motion_disposition is NULL"); $motions->execute(); while ( $row = $motions->fetch(PDO::FETCH_ASSOC)) { ?> <tr> <td><input type="radio" name="<?php $row['motion_id']?>" id="<?php $row['motion_id']?>" value="<?php $row['motion_id']?>"</td> <td><?php echo $row['motion_name']; ?> </td> <td><?php echo $row['dateadded']; ?> </td> </tr> <?php }//end of while ?> </table> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form> When it goes to the page nothing is sent over when I print the $_POST array. I know I am missing something small but I can not put my finger on it Any help would be much appreciated. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted February 26, 2017 Share Posted February 26, 2017 If you don't know how to inspect the page source in your browser, learn it. That's definitely a skill every web programmer needs. The source will tell you that all input names are empty. This is also not how radio buttons work. All buttons must have the same name (like "motion"). That's how the browser knows they belong together. Quote Link to comment Share on other sites More sharing options...
mbrown Posted February 26, 2017 Author Share Posted February 26, 2017 Jaques1 thank you for the quick response. I see what you are saying. So what I want to do is provide the a list of all motions and they will choose one to vote on. What would be the best way to do this? Would it better to make each row a form and have a submit button for each row? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted February 26, 2017 Share Posted February 26, 2017 Like I said: All buttons must have the same name (like "motion"). That's how the browser knows they belong together. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted February 27, 2017 Share Posted February 27, 2017 When it goes to the page nothing is sent over when I print the $_POST array. You are missing "echo" in a few spots. Take a closer look at the following line: <td><input type="radio" name="<?php $row['motion_id']?>" id="<?php $row['motion_id']?>" value="<?php $row['motion_id']?>"</td> Quote Link to comment 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.