Ich habe erhalten folgende Tabelle als Ergebnis dieser MySQL-AnweisungWie verbergen der abgerufenen Datenwerte mit PHP und codeigniter
SELECT * FROM expenses, income
WHERE expenses.projectname=income.projectname
AND expenses.task=income.task
Dies sind die Felder in meiner Projekttabelle
Dies sind die Felder meiner Aufgabentabelle
In dieser Tabelle hat ein Projekt viele Aufgaben. Daher wiederholen sich Projekt-, Client-, Projektanfangs- und Enddatumsspalte sinnlos. Wie kann ich sie nur einmal für alle Aufgaben zeigen? Wie kann ich hier PHP-Logik verstecken? Das folgende Diagramm zeigt, was ich erreichen muss. Daten werden durch MySQL-Abfrage abgerufen. Aber wie kann ich unnötige Werte verbergen sich wiederholende Dies ist die CodeIgniter Ansicht Seite
<table class="table table-lg">
<thead >
<tr class="filters">
<th><input type="text" class="form-control" placeholder="Project" disabled></th>
<th><input type="text" class="form-control" placeholder="Employee" disabled></th>
<th><input type="text" class="form-control" placeholder="Task" disabled></th>
<th><input type="text" class="form-control" placeholder="Expense" disabled></th>
<th><input type="text" class="form-control" placeholder="Amount" disabled></th>
<th><input type="text" class="form-control" placeholder="Paid/Not" disabled></th>
<th><input type="text" class="form-control" placeholder="Client" disabled></th>
<th><input type="text" class="form-control" placeholder="Cost" disabled></th>
<th><input type="text" class="form-control" placeholder="Income " disabled></th>
<th><input type="text" class="form-control" placeholder="Date" disabled></th>
</tr>
</thead>
<tbody>
<?php
if(isset($view_data1) && is_array($view_data1) && count($view_data1)): $i=1;
foreach ($view_data1 as $key => $data) {
?>
<tr <?php if($i%2==0){echo 'class="even"';}else{echo'class="odd"';}?>>
<td><?php echo $data['projectname']; ?></td>
<td><?php echo $data['employee']; ?></td>
<td><?php echo $data['task']; ?></td>
<td><?php echo $data['ExpenseName']; ?></td>
<td><?php echo $data['ExpenseAmount']; ?></td>
<td><?php echo $data['pn']; ?></td>
<td><?php echo $data['cname']; ?></td>
<td><?php echo $data['taskcost']; ?></td>
<td><?php echo $data['amount']; ?></td>
<td><?php echo $data['datetimepicker_mask']; ?></td>
</tr>
<?php
$i++;
}
else:
?>
<tr>
<td colspan="7" align="center" >No Records Found..</td>
</tr>
<?php
endif;
?>
</tbody>
</table>
Ihr Bild Link – JYoThI
@JYoThI gebrochen ist es nicht die Verbindung unterbrochen. Bitte sehen Sie meine bearbeitete Version – Dushee
Vielleicht kann die SQL 'GROUP BY' Ihnen dabei helfen: https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html - Etwas wie' SELECT Projektname, ANY_VALUE (Aufgabe) FROM Ausgaben, Einkommen WHERE Spesen.Projektname = Einkommen.Projektname UND Spesen.task = Einkommen.Task GROUP BY Projektname' – Bellian