0

I'm generating this table from data passed back from my controller the issue I'm having is that in general the first record returned [ in this case Sephen C. Cox], the "add employee" button does not redirect me but for the rest of the records it works. Does anyone know the problem?

enter image description here

<fieldset id= "results">                
<?php if (isset($results ) And count($results)) : ?>
<table id="box-table-a" summary="Employee Sheet">
        <thead>
            <tr>
                <th scope="col">Employee</th>
                <th scope="col">Salary</th>
                <th scope="col">Bonus</th>
                <th scope="col">Supervisor</th>
                <th scope="col">Action</th>
                </tr>


    <?php foreach ($results as $result) : ?>
    <tr>
    //Primary key <?php echo $result['Employee_ID!'];?>
    <td><span class="Employee_name"><?php echo $result['Employee']; ?> </span></td>         
    <td><span class="Salary"><?php echo $result['Salary']; ?> </span> </td>
    <td><span class="Bonus"><?php echo $result['Bonus']; ?> </span> </td>
    <td><span class="Supervisor_name"><?php echo $result['Supervisor']; ?> </span></td>
    <form action="welcome.php" method="post">   <td><input type="submit" value="Add employee" name="submit[<?php echo $result['Employee_ID'] ?>]" > </td></form>
    </tr>

        <?php endforeach; ?>
        <?php endif; ?>
        </thead>
        <tbody>
        </fieldset>
3
  • 1
    Have you tried different browsers? I'm guessing this might be caused by your submit button name attribute. I would just switch the name with the value and the value as name. Edit; Also escape the value for illegal value characters. Commented Aug 29, 2012 at 11:04
  • It is weird that you create a form outside <td>. Also, as you setup a form, it is better to pass the Employee ID via hidden input type. Commented Aug 29, 2012 at 11:07
  • can you give me an example how I would pass then call it in my controller? Commented Aug 29, 2012 at 11:24

1 Answer 1

2
<form action="welcome.php" method="post">
  <td>
     <input type="submit" value="Add employee"
     name="submit[<?php echo $result['Employee_ID'] ?>]" > 
 </td></form>

change to

<td>
 <form action="welcome.php" method="post">
     <input type="submit" value="Add employee"
     name="submit[<?php echo $result['Employee_ID'] ?>]" >
  </form>

Or even wrap the whole table into one form instead of putting new form into each row. See no any reason in your code why that could be needed

Edit: Also, take a look at tools like Firebug (FF), Inspector in Chrome and Safary, Developer Tools, or how it is called, in IE. It was completely enough to open you page with one of those tools and notice that browser parsed your code not like you expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.