I am sure that this is not a good idea!
You are creating 7 forms with the same id-name! Suggest you move the
form creation outside the loop and make your submit button provide the
correct duty id.

[code]
<?php echo $form->create('Duty', array('action' =>
'displayDutyDetails')); ?>
<table cellpadding="0" cellspacing="0">
<?php foreach($duties as $duty): ?>
<tr>
   <td><?php echo $duty['Area']['area']; ?></td>
   <td><?php echo $duty['Station']['station_name']; ?></td>
   <td><?php echo $duty['Bcu']['bcu']; ?></td>
   <td><?php echo $duty['Duty']['duty_date']; ?></td>
   <td><?php echo $duty['Duty']['on_duty']; ?></td>
   <td><?php echo $duty['Duty']['off_duty']; ?></td>
   <td><?php echo $duty['Duty']['remarks']; ?></td>
   <td width="40px"><?php echo $form->submit('../img/icons/view.png',
      array('label'=>'View', 'duty_id' => $duty['Duty']['duty_id'],
      'width' => '40px', 'height' =>'25px',
      'onmouseover' => 'javascript:this.src="../img/icons/
      view_over.png"',
      'onmouseout' => 'javascript:this.src="../img/icons/view.png"'));?
>
    </td>
</tr>
<?php endforeach; ?>
</table>
<?php echo $form->end();?>
[/code]

Observe that the table is inside the form. You had a mixup with the
sequence of the table and the form tags.
Enjoy,
   John

On Jan 14, 11:57 am, Bailey <baileys...@gmail.com> wrote:
> Hi all,
>
> I'm trying to display data in a html table from a database query.
>
> The data appears but I want to be able to provide an option from each
> record shown in the html table, i.e. (view more details button).
>
> I do this by creating a form inside the php loop that generates the
> table data. The form holds a hidden field that stores the record id i
> want to look up further with another function in the controller. In
> firefox this works perfectly but in IE it screws up, the button's dont
> appear and I get extra tables appearing above the results table that
> matches the same number of records in that table.
>
> (i.e. loop goes through 7 times, prints out 7 lots of data, but prints
> out 7 extra tables above).
>
> I'm sure theres a simple fix to this but i'm having real difficulty
> finding it. Does anyone know of anything i can do to fix this (or if
> theres another means that I can achieve the same result)? my table
> code is below, i'm not using any other styling at the moment apart
> from the cakephp default one.
>
> Many thanks!
>
> Code - View.ctp
> ==============================================================================
>
> <?php foreach($duties as $duty): ?>
> <?php
>         echo $form->create('Duty', array('action' => 'displayDutyDetails'));
>         echo $form->hidden('duty_id',array('value' => $duty['Duty']
> ['duty_id']));?>
>
> <table cellpadding="0" cellspacing="0">
> <tr>
>         <td><?php echo $duty['Area']['area']; ?></td>
>         <td><?php echo $duty['Station']['station_name']; ?></td>
>         <td><?php echo $duty['Bcu']['bcu']; ?></td>
>         <td><?php echo $duty['Duty']['duty_date']; ?></td>
>         <td><?php echo $duty['Duty']['on_duty']; ?></td>
>         <td><?php echo $duty['Duty']['off_duty']; ?></td>
>         <td><?php echo $duty['Duty']['remarks']; ?></td>
>
>         <td width="40px"><?php echo $form->submit('../img/icons/view.png',
>                         array('label'=>'View', 'width' => '40px', 'height' 
> =>'25px',
>                         'onmouseover' => 'javascript:this.src="../img/icons/
> view_over.png"',
>                         'onmouseout' => 
> 'javascript:this.src="../img/icons/view.png"'));?>
>         </td>
>         <?php echo $form->end();?>
> </tr>
> <?php endforeach; ?>
> </table>
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to