我确信这很简单,但我一直试图让这个很久.我有一个foreach循环,它遍历一个对象数组,并在一个带有提交按钮的html表中显示它们,当点击它时会进行ajax调用以在同一页面中显示一些数据.
这一切都正常,除了它只传递foreach循环中数组中最后一个对象的值,而不是该表行中显示的值.我试图使用一个计数器或设置和id为但不确定如何获得该特定值并传递它.
这是我的代码中的内容:
<?php
// No direct access
defined('_JEXEC') or die; ?>
<div class="status shelterbuddydog" >
<table class="profile_table">
<?php foreach ($animalDetails as $profile):?>
<tr>
<td><?php echo $profile->photo;?></td>
<td><span class="profile">Name:<?php echo $profile->name;?></span><br/>
<span class="profile">Sex: <?php echo $profile->sex;?></span></<br/>
<span class="profile">Age: <?php echo $profile->age;?></span><br/>
<span class="profile">Breed: <?php echo $profile->breed;?></span><br/>
<span class="profile">Animal Id: <?php echo$profile->animalId;?></span><br/>
<span class="profile">Location: <?php echo $profile->shelter;?></span><br/>
<?php $profile->summary;?>
<input type="submit" id="summary" name="summary" value="VIEW MY PROFILE">
</input></td>
</tr>
<?php endforeach;
</table>
<?php
// Instantiate global document object
$doc = JFactory::getDocument();
$js …Run Code Online (Sandbox Code Playgroud)