Hey can anyone tell my why this code isn't working. The table loads, all the data come from the database in the 'foreach' PHP loop just fine but the 3 pieces of data for 'code' 'summer_program' and 'school_organization' don't load.
I just can't work out why.
Cheers
I just can't work out why.
Cheers
<table>
<tr>
<td>
<strong>Code:</strong><?php $detail = $form->data['code']; ?><br/>
<strong>Program:</strong><?php $detail = $form->data['summer_program']; ?> <strong>School: </strong><?php $detail = $form->data['school_organization'];?>
</td>
</tr>
</table>
<table width="590px" style="text-align: left;" >
<tr>
<th width="20%"><strong>Surname:</strong></th>
<th width="20%"><strong>First Name:</strong></th>
<th width="20%"><strong>Passport/ID:</strong></th>
<th width="20%"><strong>Birthday:</strong></th>
<th width="20%"><strong>Phone:</strong></th>
</tr>
<?php
foreach ($form->data['ProgramList'] as $detail):
?>
<tr>
<td><?php echo $detail['surname']; ?></td>
<td><?php echo $detail['given_name']; ?></td>
<td><?php echo $detail['passport']; ?></td>
<td><?php echo $detail['phone']; ?></td>
<td><?php echo $detail['bd_day'] ?> <?php echo $detail['bd_month'] ?> <?php echo $detail['bd_year']; ?></td>
</tr>
<?php
endforeach;
?>
</table>
Hi,
Just like your other code snippets, instead of this:
You should use this:
Regards,
Max
Just like your other code snippets, instead of this:
<?php $detail = $form->data['summer_program']; ?>
You should use this:
<?php echo $form->data['summer_program']; ?>
Regards,
Max
[attachment=0]screen-capture-1.png[/attachment]Hmm ok so I did what you said, my code is now this:
And the result is this:
[attachment=0]screen-capture-1.png[/attachment]
I can't see why it wouldn't work
Thanks again for everything
<table>
<tr>
<td>
<strong>Code: </strong><?php echo $form->data['code']; ?><br/>
<strong>Program: </strong><?php echo $form->data['summer_program']; ?> <strong>School: </strong><?php echo $form->data['school_organization']; ?>
</td>
</tr>
</table>
<table width="590px" style="text-align: left;" >
<tr>
<th width="20%"><strong>Surname:</strong></th>
<th width="20%"><strong>First Name:</strong></th>
<th width="20%"><strong>Passport/ID:</strong></th>
<th width="20%"><strong>Phone:</strong></th>
<th width="20%"><strong>Date of Birth:</strong></th>
</tr>
<?php
foreach ($form->data['ProgramList'] as $detail):
?>
<tr>
<td><?php echo $detail['surname']; ?></td>
<td><?php echo $detail['given_name']; ?></td>
<td><?php echo $detail['passport']; ?></td>
<td><?php echo $detail['phone']; ?></td>
<td><?php echo $detail['bd_day'] ?> <?php echo $detail['bd_month'] ?> <?php echo $detail['bd_year']; ?></td>
</tr>
<?php
endforeach;
?>
</table>
And the result is this:
[attachment=0]screen-capture-1.png[/attachment]
I can't see why it wouldn't work
Thanks again for everything
I've spent endless hours looking and experiencing but still no luck. Any idea? Thanks
Ok the only way I can get it to work is like this
But that of course generates the table twice
[attachment=0]screen-capture.png[/attachment]
What do I change the outer 'foreach' loop to so that it only does it once... sorry my PHP is rubbish.
Thanks again for looking at this!
<table>
<?php
foreach ($form->data['ProgramList'] as $detail):
?>
<tr>
<td>
<strong>Code: </strong><?php echo $detail['code']; ?><br/>
<strong>Program: </strong><?php echo $detail['summer_program']; ?> <strong>School: </strong><?php echo $detail['school_organization']; ?>
</td>
</tr>
</table>
<table width="590px" style="text-align: left;" >
<tr>
<th width="20%"><strong>Surname:</strong></th>
<th width="20%"><strong>First Name:</strong></th>
<th width="20%"><strong>Passport/ID:</strong></th>
<th width="20%"><strong>Phone:</strong></th>
<th width="20%"><strong>Date of Birth:</strong></th>
</tr>
<?php
foreach ($form->data['ProgramList'] as $detail):
?>
<tr>
<td><?php echo $detail['surname']; ?></td>
<td><?php echo $detail['given_name']; ?></td>
<td><?php echo $detail['passport']; ?></td>
<td><?php echo $detail['phone']; ?></td>
<td><?php echo $detail['bd_day'] ?> <?php echo $detail['bd_month'] ?> <?php echo $detail['bd_year']; ?></td>
</tr>
<?php
endforeach;
?>
<?php
endforeach;
?>
</table>
But that of course generates the table twice
[attachment=0]screen-capture.png[/attachment]
What do I change the outer 'foreach' loop to so that it only does it once... sorry my PHP is rubbish.
Thanks again for looking at this!
Hi,
Well, maybe I didn't understand your question first, the code depends on how many "Code", "Program" and "School" you want to display, if you have one of those for every record then they should be inside the loop, but if you have them only once then they should be out.
If you have them in each record but they are all the same then you may use the 0 key to get them from the array outside the loop:
Regards,
Max
Well, maybe I didn't understand your question first, the code depends on how many "Code", "Program" and "School" you want to display, if you have one of those for every record then they should be inside the loop, but if you have them only once then they should be out.
If you have them in each record but they are all the same then you may use the 0 key to get them from the array outside the loop:
echo $form->data['ProgramList'][0]['code'];
Regards,
Max
This topic is locked and no more replies can be posted.