我是一名前端开发人员,对PHP开发来说是一个新手。这是我的问题。 我正在使用当前调用以下内容的文件。区域名称,商店ID,视图存储照片。它可以很好地检索值。我需要做的是添加每个商店有多少活动和可见照片的计数。
示例:(当前显示)
Region Name Store ID View Stores Photos
1 Northeast 1445 View Store Photos
示例:(需要)
Region Name Store ID Active Visible View Stores Photos
1 Northeast 1445 2 1 View Store Photos
问题是当我尝试显示时,根本没有返回任何值,即使对于现有数据也没有。
活动列和可见列位于另一个表'sample_table'
中以下是代码:
case 'showStores':
//check sortby
// set up order by code here
$orderByThis = 'utts.tf_store_id';
$orderByDirection = 'ASC';
$link_ob_dir = 2;
if($_REQUEST['dir'] == 2){
$orderByDirection = 'DESC';
$link_ob_dir = 1;
}//End if($_REQUEST['dir'] == 2)
if($_REQUEST['ob'] == 'regionID') $orderByThis = 'sr.store_region_id';
if($_REQUEST['ob'] == 'regionName') $orderByThis = 'sr.store_region';
if($_REQUEST['ob'] == 'userID') $orderByThis = 'ut.user_id';
if($_REQUEST['ob'] == 'name') $orderByThis = 'u.first_name';
if($_REQUEST['ob'] == 'email') $orderByThis = 'u.email';
if($_REQUEST['ob'] == 'storeID') $orderByThis = 'utts.tf_store_id';
if($_REQUEST['ob'] == 'active') $orderByThis = 'msws.active';
if($_REQUEST['ob'] == 'visible') $orderByThis = 'msws.visible';
//get all rep's stores and their region, store_id, store name, address
$getStoresSQL = " Select ut.store_region_id, ut.user_id, sr.store_region, u.first_name, u.last_name, u.email,
msws.active, msws.visible, utts.tf_store_id
From `store_region` as sr
Left Join `user_tracfone` as ut on(ut.store_region_id = sr.store_region_id)
Left Join `user` as u on(u.user_id = ut.user_id)
Left Join `user_tracfone_to_store` as utts on(utts.user_id = ut.user_id)
Where ut.user_id = '".$currentRep."'
And sr.program_id = 88
And ut.active = 1
And utts.active = 1
And utts.program_id = 88
group by utts.tf_store_id
Order By ".$orderByThis." ".$orderByDirection." ";
$getStoresSQLResult = $manager->getEntities2("User_tracfone",$getStoresSQL);
//get reps info
$repsInfo = $manager->getEntities("User",0,"`user_id`='".$currentRep."' ");
//get this reps manager id
$repsManagerInfo = $manager->getEntities("User_tracfone",0,"`user_id`='".$currentRep."' ");
$imageActive = $manager->getEntities("Ms_winner_story",0,"`active`='".$_SESSION['Active']['active']."'");
$imageVisible = $manager->getEntities("Ms_winner_story",0,"`visible`='".$_SESSION['Visible']['visible']."'");
//prep table
$back ='';
if($isTracfone == true || $isManager == true){
$back = '<a href="managePhotos.php?process=showReps&manager='.$repsManagerInfo[0]->manager_user_id.'" title=""><b><<< Back to Feild Reps</b></a>';
}//End
$outPut =' <table width="75%">
<tr>
<td><b>'.$repsInfo[0]->first_name.' '.$repsInfo[0]->last_name.'\'s Stores</b></td>
<td align="right">'.$back.'</td>
</tr>
</table>';
$outPut .= '<table width="95%" cellpadding="0" cellspacing="0">
<tr class="cellHeader">
<td></td>
<!--<td ><a href="managePhotos.php?process=showStores&rep='.$currentRep.'&dir='.$link_ob_dir.'&ob=regionID">Region ID</a></td>-->
<td ><!--<a href="managePhotos.php?process=showStores&rep='.$currentRep.'&dir='.$link_ob_dir.'&ob=regionName">-->Region Name<!--</a>--></td>
<td ><a href="managePhotos.php?process=showStores&rep='.$currentRep.'&dir='.$link_ob_dir.'&ob=storeID">Store ID</a></td>
<td ><!--<a href="managePhotos.php?process=showStores&rep='.$currentRep.'&dir='.$link_ob_dir.'&ob=active">-->Active Photos<!--</a>--></td>
<td ><!--<a href="managePhotos.php?process=showStores&rep='.$currentRep.'&dir='.$link_ob_dir.'&ob=visible">-->Visible Photos<!--</a>--></td>
<td>View Stores Photos</td>
</tr>
';
//loop through records and concat output
$recordCount = 0;
foreach( $getStoresSQLResult as $key =>$gssqlr ){
$recordCount++;
$outPut .= '<tr bgcolor="'.$rowColor.'">
<td><span style="font-size:10pt;">'.$recordCount.' </td>
<!--<td><span style="font-size:10pt;">'.$gssqlr->store_region_id.' </td>-->
<td><span style="font-size:10pt;">'.$gssqlr->store_region.'</span></td>
<td><span style="font-size:10pt;">'.$gssqlr->tf_store_id.'</span></td>
<td><span style="font-size:10pt;">'.$gssqlr->active.'</span></td>
<td><span style="font-size:10pt;">'.$gssqlr->visible.'</span></td>
<td>
<span style="font-size:10pt;">
<a href="managePhotos.php?process=showImages&rep='.$currentRep.'&store='.$gssqlr->tf_store_id.'" title="View images for this store." >View Store Photos</a>
</span>
</td>
</tr>';
if($oddRowColor == false){
$rowColor = '#f2f2f2';
$oddRowColor = true;
}else{
$rowColor = '#ffffff';
$oddRowColor = false;
}//End if($oddRowColor == false){
}//End foreach($getManagersSQLResult as $gmsqlr)
$outPut .='</table><br/>';