问题:如何让代码调出用户的名字或全名? 这是我在example.com/views/user/index.ctp
下面的部分php代码 <?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>
<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(); ?> <?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-
此代码来自用户文件夹的索引页。需要有关如何添加客户全名或至少名字的帮助。
答案 0 :(得分:0)
使用php explode方法。
BigDecimal