Jump to content

Code not printing out


mbrown

Recommended Posts

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. 
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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? 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.