我已经创建了两个时间表,一个是登录用户创建其客户端的接口,另一个是将这些客户端及其详细信息显示给同一个登录用户的表单。
这是我在Chronoforms元素中放置的代码:
<?php
defined('_JEXEC') or die();
$user =& JFactory::getUser();
$usr_id = $user->get('id');
$usr_name = $user->get('name');
echo $usr_id;
$db = &JFactory::getDBO();
$query = "SELECT * FROM crd_chronoforms_data_RepsClient WHERE cf_created_by = '$usr_id'";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach($form->data['crdchronoformsdataRepsClient'] as $detail);
?>
<table>
<tr>
<th>Client</th>
<th>Contact Name</th>
<th>Contact Number</th>
<th> </th>
</tr>
<tr>
<td><?php echo $detail['cf_rep_client'];?></td>
<td><?php echo $detail['cf_rep_contact'];?></td>
<td><?php echo $detail['cf_rep_tel'];?></td>
<td><a href="index.php?option=com_chronoforms&chronoform=reps_clients&token=<?php echo $detail['cf_uid'];?>">Edit</td>
</tr>
</table>但是,目前所显示的所有列表都是登录用户ID#。
回声$usr_id;
我不知道我的语法在哪里出问题了。任何帮助和新的眼睛都是非常感谢的。
新的错误..。
致命错误:不能在第26行的/home/cardosoc/public_html/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19):eval()d代码中使用stdClass类型的对象作为数组
<?php
$user = JFactory::getUser();
$usr_id = $user->id;
$usr_name = $user->username;
echo $usr_name;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*')
->from('#__chronoforms_data_RepsClient')
->where('cf_created_by ='. $usr_id);
$db->setQuery($query);
$data = $db->loadObjectList();
foreach($data as $detail):
?>
<table>
<tr>
<th>Client</th>
<th>Contact Name</th>
<th>Contact Number</th>
<th>Address</th>
<th> </th>
</tr>
<tr>
<td><?php echo $detail['rep_client'];?></td>
<td><?php echo $detail['rep_contact'];?></td>
<td><?php echo $detail['rep_tel'];?></td>
<td><?php echo $detail['rep_client_address'];?></td>
<td><a href="index.php?option=com_chronoforms&chronoform=reps_clients&token=<?php echo $detail['cf_uid'];?>">Edit</td>
<?php endforeach; ?>
</tr>
</table>但是..。如果我更改
foreach($data as $detail):foreach($db as $detail):
我得到的回应是
m m m m 发布于 2013-05-30 15:12:56
尝试使用它,它使用Joomla2.5编码标准+一些更改:
$user = JFactory::getUser();
$usr_id = $user->id;
$usr_name = $user->username;
echo $usr_id;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*')
->from('#__crd_chronoforms_data_RepsClient')
->where('cf_created_by = ' . $usr_id);
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ($data as $detail) : ?>
<table>
<tr>
<th>Client</th>
<th>Contact Name</th>
<th>Contact Number</th>
<th> </th>
</tr>
<tr>
<td><?php echo $detail['cf_rep_client'];?></td>
<td><?php echo $detail['cf_rep_contact'];?></td>
<td><?php echo $detail['cf_rep_tel'];?></td>
<td><a href="index.php?option=com_chronoforms&chronoform=reps_clients&token=<?php echo $detail['cf_uid'];?>">Edit</td>
</tr>
</table>
<?php endforeach; ?>您也没有正确地定义数据库表。如果这有用的话请告诉我。
https://stackoverflow.com/questions/16829699
复制相似问题