gpt4 book ai didi

mysql - 合并具有使用 codeigniter 和 mysql 动态生成的不同货币的同一用户的行

转载 作者:行者123 更新时间:2023-11-28 05:18:57 28 4
gpt4 key购买 nike

使用按货币 ID 分组,我列出了所有用户及其金额。现在相同的用户显示在多行中。我需要在同一行显示。

来自模型类的我的 sql 查询

SELECT pay_date, 
sub_ins_name AS name,
Sum(iman_sub_product_payment_details.amtreceived) AS amount,
Sum(iman_sub_product_payment_details.refundedamt) AS refamount,
iman_sub_product_payment_details.subscriber_id AS subid,
iman_sub_product_payment_details.cur_id AS cur_id
FROM iman_subscriber_insitution_details
LEFT JOIN `iman_sub_product_payment_details`
ON
`iman_sub_product_payment_details`.`subscriber_id` = `iman_subscriber_insitution_details`.`sub_institute_id`
WHERE iman_sub_product_payment_details.pay_date >= Date("2016-01-01")
AND iman_sub_product_payment_details.pay_date <= Date("2016-08-01")
GROUP BY iman_subscriber_insitution_details.sub_institute_id,
iman_sub_product_payment_details.cur_id
UNION
SELECT pay_date,
agentname AS name,
Sum(iman_sub_product_payment_details.amtreceived) AS amount,
Sum(iman_sub_product_payment_details.refundedamt) AS refamount,
iman_sub_product_payment_details.subscriber_id AS subid,
iman_sub_product_payment_details.cur_id AS cur_id
FROM iman_agent_details
LEFT JOIN `iman_sub_product_payment_details`
ON `iman_sub_product_payment_details`.`dealer_id` =
`iman_agent_details`.`agentid`
WHERE iman_sub_product_payment_details.pay_date >= Date("2016-01-01")
AND iman_sub_product_payment_details.pay_date <= Date("2016-08-01")
GROUP BY iman_agent_details.agentid,
iman_sub_product_payment_details.cur_id
UNION
SELECT pay_date,
resname AS name,
Sum(iman_resource_payment_details.rec_amt) AS amount,
Sum(iman_resource_payment_details.refundedamt) AS refamount,
iman_resource_payment_details.status AS subid,
iman_resource_payment_details.curid AS cur_id
FROM iman_other_resources
LEFT JOIN iman_resource_payment_details
ON `iman_resource_payment_details`.`resourceid` =
iman_other_resources.`id`
WHERE iman_resource_payment_details.pay_date >= Date("2016-01-01")
AND iman_resource_payment_details.pay_date <= Date("2016-08-01")
GROUP BY iman_other_resources.id,
iman_resource_payment_details.curid
ORDER BY name ASC

查看页面

<table class="table table-hover tablesorter" border="0">
<tbody>
<tr>
<th>
<label>From Date</label>
</th>
<td>:</td>
<td>
<input type="text" name="from_date" id="from_date" value="<?=$fromdate?>">
</td>

<th>
<label>To Date</label>
</th>
<td>:</td>
<td>
<input type="text" name="to_date" id="to_date" value="<?=$todate?>">
</td>
<th>
<label>List By</label>
</th>
<td>:</td>
<td>
<select class="sel_listby" name="sel_listby" id="sel_listby">
<option value="0">--Select---</option>
<option value="institution" <?php if ($listby=='institution' ) echo 'selected="selected"'; ?>>Institution</option>
<option value="dealer" <?php if ($listby=='dealer' ) echo 'selected="selected"'; ?>>Dealer</option>
<option value="or" <?php if ($listby=='or' ) echo 'selected="selected"'; ?>>Other Resources</option>
</select>
</td>
</tr>
<tr>
<th>
<label>From Amount</label>
</th>
<td>:</td>
<td>
<input type="text" name="from_amount" id="from_amount" value="<?=$from_amount?>">
</td>
<th>
<label>To Amount</label>
</th>
<td>:</td>
<td>
<input type="text" name="to_amount" id="to_amount" value="<?=$to_amount?>">
</td>
<th>
<label>Category</label>
</th>
<td>:</td>
<td>
<select class="sel_category" name="sel_category" id="sel_category">
<option value="0">--Select---</option>
<?php foreach($subcategory as $val): ?>
<option value="<?=$val->subscriptionid ?>" <?php if ($val->subscriptionid==$subcat) echo 'selected="selected"'; ?>>
<?=$val->subscriptionname?></option>
<?php endforeach ?>
</select>
</td>
</tr>
<tr>
<th>
<label>Currency</label>
</th>
<td>:</td>
<td>
<select class="sel_cur" name="sel_cur" id="sel_cur" onchange="fncSubmit();">
<option value="0">--Select---</option>
<?php $i=0; foreach($cur as $val): ?>
<option value="<?=$val->priceid?>" <?php if ($val->priceid==$currency) echo 'selected="selected"'; ?>>
<?=$val->pricename?></option>
<?php $i++;endforeach ?>
</select>
</td>
<th>
<label>Sort By</label>
</th>
<td>:</td>
<td>
<select class="sel_sortby" name="sel_sortby" id="sel_sortby">
<option value="0">--Select---</option>
<option value="N" <?php if ($sortby=='N' ) echo 'selected="selected"'; ?>>New </option>
<option value="R" <?php if ($sortby=='R' ) echo 'selected="selected"'; ?>>Renewal </option>
</select>
</td>
<th>
<label>Combo</label>
</th>
<td>:</td>
<td>
<input class="input" type="checkbox" name="txt_combo" id="txt_combo" value="1" maxlength="100" <?php echo $comboval==1 ? 'checked' : '';?> />

<input type="submit" name="search" value="Search" class="btn btn-success">
</td>
</tr>

<tr>
<td colspan="9">
<div id="dvData">
<div align="right">

<!--<a class="btn btn-primary" href="#" onClick="$('#tblExport').tableExport({type:'excel',escape:'false'});"><i class="fa fa-file-excel-o"></i>&nbsp; Export to Excel</a>-->
<button class="btn btn-primary" id="btnExport" onclick="fnExcelReport();"><i class="fa fa-file-excel-o"></i>&nbsp; EXPORT to Excel </button>
<!--<a class="btn btn-primary" onclick="fncExportExcel('<?=$modid?>','<?=$listby?>','<?=$fromdate?>','<?=$todate?>','<?=$prodtype?>','<?=$dealerid?>','<?=$comboval?>'); return false;">Export to excel</a>-->
</div>
<div class="with_print">
<div><b><center> Subscription Report <?php if(!empty($listby)){ ?>for <?=$listby?><?php } ?> From <?=$fromdate?> To <?=$todate?></center></b>
</div>
<table border="0" width="100%" class="TFtable" id="tblExport" style="border:1px solid black; ">
<thead>
<tr>
<th>S.No</th>
<th width="40%">
<?php if ($listby=='dealer' ){ echo "Agent Name";}else if ($listby=='or' ){ echo "Other Resource Name";}else{?>Subscriber Name
<?php } ?>
</th>
<th>Source Name</th>
<?php if($currency!=0){ ?>
<th>Amount</th>
<?php }else{ ?>
<?php foreach($cur as $val){ ?>
<th>
<?=$val->pricename?></th>
<?php } ?>
<?php } ?>
</tr>
</thead>
<tbody>
<?php $i=1; foreach($query as $val){ ?>
<tr>
<td>
<?=$i?>
</td>
<td>
<?php if ($listby=='dealer' ){ echo $val->agentname;}else if($listby=='institution'){ echo $val->sub_ins_name;}else{?>
<?=$val->name?>
<?php } ?>
</td>
<td>
<?php if ($listby=='dealer' ){ echo "Agent";}else if ($listby=='or' ){ echo "Other Resouces";}else if($listby=='institution' ){ echo "Direct";}else{if($val->subid=="OR"){echo "Other Resouces";} else if($val->subid==0){echo "Agent";} else{echo "Direct";}} ?></td>
<?php if($currency!=0){ ?>
<td>
<?=$val->amount-$val->refamount?></td>
<?php }else {?>
<?php foreach($cur as $value){ ?>
<td>
<?php if($value->priceid==$val->cur_id){echo $val->amount-$val->refamount; $curtot[$value->priceid]+=$val->amount-$val->refamount; }?>
</td>
<?php } ?>
<?php } ?>

</tr>
<?php $i++; $netamount+=$val->amount-$val->refamount; } //print_r($curtot); ?>

<tfoot>
<?php if($currency==0){ ?>
<tr>
<td></td>
<td></td>
<td><b>Total</b>
</td>

<?php foreach($cur as $value){ ?>
<td><b> <?=$curtot[$value->priceid]?> </b> </td>
<?php $gt+=$curtot[$value->priceid];} ?>

</tr>
<?php } ?>
<tr id="footerExport">

<td></td>
<td></td>
<?php if($currency==0){ ?>
<?php for($c=1;$c<count($cur);$c++){?>
<td></td>
<?php }} ?>
<td><b>Grand Total</b>
</td>
<td><b>
<?php if($currency==0){ ?>
<?=$gt?>
<?php }else{ ?>
<?=$netamount?>
<?php } ?>
</b>
</td>
</tr>
</tfoot>
</tbody>
</table>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="6">
<button id="pdf" class="btn btn-danger">Print</button>
</td>
</tr>
</tbody>
</table>

下面是我的截图

C.S.pochen&sons Usd amount:350 一行显示C.S.pochen&sons INR amount:7700 显示在另一行。

谁能帮忙合并这一行。

最佳答案

如果有更多信息,这个问题会更容易回答。

  • 您是否有权访问整个网络应用程序?
  • 这是否必须在 css 中完成?
  • 应用程序使用什么语言?
  • 分享问题涉及的代码。

通常,将这种逻辑放在 View 中是个坏主意。如果他们更改数据库并且突然间它与您的 css 中的选择器不匹配,以后会发生什么?在具有数千个条目的数据库中,数据库程序员很容易不会注意到他们无意中破坏了您的 css 规则,然后客户端可能会导出具有错误值的表。

在您的 Controller 中应该有一个语句来选择表数据并将其返回给 View 。这样做的逻辑应该在那里完成。

关于mysql - 合并具有使用 codeigniter 和 mysql 动态生成的不同货币的同一用户的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39164508/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com