dongrouyuan5685 2017-02-22 04:59
浏览 68

管理员端PHP获取用户名

Question: How can I get the code to call out users first name or fullname? Here is my partial php code below from the example.com/views/user/index.ctp

  <?php echo $javascript->link('jquery.js'); ?>
  <?php echo $javascript->link('hint.js'); ?> 
  <script language="JavaScript" type="text/JavaScript">
  function clickSearch()
  {
  document.frmUsers.submit();
  }
  </script>
  <?php if($session->check('Message.flash')) { ?><div id="okbox"><font     color="#FF0000"><?php $session->flash(); ?></font></div><?php } ?>
        <div align="left" id="item_details_admin">
            <div class="admin_subheading">Users</div>
            <!--items serach area start -->                 
                <form action="<?php echo $sitebase.$sitefolder.'/'.$this-   >params["controller"];?>" method="get" name="frmUsers">
                    <div  class="content_search_container">     
                        <select name="cmbSearchType" class="box2_admin">
                        <option value="uname"  <?php if($cmbSearchType ==     "uname" || $cmbSearchType == ""){ echo("selected"); } ?>>User Name</option>
                    <option value="email"  <?php if($cmbSearchType == "email"){ echo("selected"); } ?>>Email</option>
                        </select> &nbsp;
                        <input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>" class="box2_admin" >
                        <!--a style="cursor:pointer"     onClick="javascript:clickSearch();"><?php echo $html->image('../img/OrangeRed/search_bttn.png');?></a-->
                        <a style="cursor:pointer" onClick="javascript:clickSearch();" class="button orange">Search</a>
                        <div class="clear"></div>
                    </div>      
               </form>  
             <!--items serach area end -->          
         <?php 
                     if(isset($passedarg["direction"])){
                           if($passedarg["direction"]=="asc")
                           {
                               $keyasc = "asc";
                               $sortfield = $passedarg["sort"];
                           }
                           if($passedarg["direction"]=="desc")
                           {
                               $keydesc = "desc";
                               $sortfield = $passedarg["sort"];
                           }
                     }                       
                     ?>
         <div class="btn-pnl">
                <label><?php echo $html->link('Add New User','/users/add',array('class' => 'button white right'));?></label>
                 <?php if(count($usr)> 0) { ?>
                 <label><?php echo $html->link('Export to csv','/users/usercsv',array('class' => 'button white'));?></label>
                 <label><?php echo $html->link('Export to xls','/users/userxls',array('class' => 'button white'));?></label>
                 <?php } ?>
            <div class="clear"></div>
            </div>
             <!--items display area start -->
              <div align="center" id="items_display_area_admin" class="inner_content_area_admin_new withpadding">
                    <form name="customlist" method="post" action="/vistacart/customfieldvalues/edit">   
                        <table width="100%"  border="0" cellspacing="0" cellpadding="0" class="admin-table-list">
                          <tr>
                            <th width="5%">#</th>
                                                            <th width="20%"><?php echo $paginator->sort('User Name', 'uname'); ?>
                                                                <?php     if($sortfield=="uname") 
                                                                 {
if(isset($keyasc))
                                                                    { echo $html->image('../img/up-arrow.png');}elseif(isset ($keydesc)){echo $html->image('../img/down-arrow.png');}
                                                                 }
                                                                    ?>
                                                            </th>
                                                             <th width="20%"><?php echo $paginator->sort('Cust. Name', 'fname'); ?>
                                                                <?php if($sortfield=="fname") 
                                                                 {
 if(isset($keyasc))
                                                                    { echo $html->image('../img/up-arrow.png');}elseif(isset ($keydesc)){echo $html->image('../img/down-arrow.png');}}
                                                                    ?>
                                                            </th>
                            <th width="25%"><?php echo $paginator->sort('Email', 'email'); ?>
                                                             <?php if($sortfield=="email") 
                                                                 {
if(isset($keyasc))
                                                                    { echo    $html->image('../img/up-arrow.png');}elseif(isset ($keydesc)){echo $html-   >image('../img/down-arrow.png');}
                                                                 }
                                                                    ?>
                                                            </th>
                            <th width="8%">Options</th>
                          </tr>
                            <?php
                            if(!empty($passedarg) &&    !isset($passedarg["page"]))                             
                                $cnt=1;
                                else if(!empty($passedarg) &&     $passedarg["page"]==1)
                                $cnt=1;
                                else
                                $cnt=((($passedarg["page"]-1)*   ($passedarg["limit"]))+1);
                           if(!empty($usr)){
                foreach ($usr as $user){?>   
                          <tr>
                            <td><?php echo $cnt++;?></td>
                            <td>
                                <?php 
                                                         $uname=Sanitize::html($user['User']['uname']);
                                                     if(strlen($uname)> 20)
                                                     {
                                                      $uname=substr($uname,     0, 20)."..."; ?>
                                                      <a href="#"     class="tooltip" title="<?php echo Sanitize::html($user['User']['uname']); ?>" style="text-decoration:none;" onclick="return false;">
                                                      <?php echo $uname; ?>
                                                      </a>  
                                                      <?php } else {
                                                      echo $uname; }?>  
                            </td>
                            <td>
             //Will add php code for users full or first name here.
</td>
</td>
<td>
<?php 
$emailaddress=Sanitize::html($user['User']['email']);
if(strlen($emailaddress)> 25)
                                                     {
$emailaddress=substr($emailaddress, 0, 25)."..."; ?>
                                                      <a href="#"     class="tooltip" title="<?php echo Sanitize::html($user['User']['email']); ?>"     style="text-decoration:none;" onclick="return false;">
                                                      <?php echo     strtolower($emailaddress); ?>
                                                      </a>  
                                                      <?php } else {
                                                      echo     strtolower($emailaddress); }?>       
                            </td>
                            <td>
                            <?php echo $html->link('Edit', 
            "/users/edit/".$user['User']['id'])." / ".$html->link('Delete', 
            "/users/delete/".$user['User']['id'],null,'Are you sure to     delete this User?'); ?>
                            </td>                               
                          </tr>
                          <?php } ?>
                          <tr>
                            <td colspan="4" style="text-align:right "><?php 
                                  if($cmbSearchType <> '' &&  $txtSearch <>     ''){
                                   $paginator-        >options(array('url'=>array_merge(array('cmbSearchType'=>$cmbSearchType,
                                   'txtSearch'=>$txtSearch),$this-    >passedArgs))); }  ?>
                                                     <?php echo $paginator-    >numbers(); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $paginator->counter(); ?>        </td>                                
                          </tr>
                          <?php } else { ?>
                                  <tr><td colspan="4">Sorry no users found!     </td></tr>

                         <?php } ?>
                        </table>                                        
</div>                          
 <div align="left" class="float_clear1"></div>
</div>
  <div align="left" class="float_clear1"><?php echo $html-        

This code is from index page from user folder. Need help with how to add customers full name or at least first name.

  • 写回答

1条回答 默认 最新

  • dsadasd12132 2017-02-22 05:08
    关注

    Use php explode method.
    $userArray = explode(' ', $username); $username = $userArray[0];

    评论

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装