2013-05-30 72 views
0

我创建了2个时间表,其中一个登录用户创建其客户端的连接,第二个是显示这些客户端及其客户端列表的表单详细信息以相同的登录用户。计时表显示当前登录用户创建它们的“客户端详细信息”列表

这是我放置在定制代码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>&nbsp;</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#即

echo $usr_id;

我不知道我的语法已经被轰炸了。任何帮助和新鲜的眼睛都会感激。


新的错误,现在...

Fatal error: Cannot use object of type stdClass as array in /home/cardosoc/public_html/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 26

 <?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>&nbsp;</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): TO foreach($db as $detail):

我得到的响应

m m m m 
+0

foreach($ form-> data ['crdchronoformsdataRepsClient'] as $ details); – Sundar

+0

看到'$ details'并改变了它... – MrMage

回答

1

尝试使用这种它使用的Joomla 2.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>&nbsp;</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; ?> 

你没有定义数据库表或者正确。让我知道这个是否奏效。

+0

嗨Lodder 我给它一个镜头,它看起来似乎可能工作,但是当我尝试使用'foreach'或者'?php echo $时抛出错误细节[''等我曾尝试过各种不同的事情,我试着放弃'foreach'声明而不是'$ detail'我尝试过'$ db'和'$ query' ..但仍然抛出错误。再次感谢您的意见,我很感激! – MrMage

+0

@ user1395580 - 我用完整的代码更新了我的答案。尝试一下,并让我知道 – Lodder

+0

嗨Lodder我试了一下,它有效,如果我出于某种原因将'$ data'更改为'$ db'? – MrMage

相关问题