i am developing a blood bank management system. Now i want to display that how many times each user donated blood, i mean i want to get the sum of each user row. For example if a donor(who's passport/IC is AF3444547)has 3 row in the database so i need show the total row from the database.If next time i put another record of AF3444547 then i need to get the sum 4. The image shown in below of my databse. Thanks in advance
Here is my code
<?php
$passport_IC='passport_IC';
$q="SELECT passport_IC, count(*) FROM donate GROUP BY passport_IC";
$query=$db->prepare($q);
$query->execute(array($passport_IC));
$people = $query->fetchAll(PDO::FETCH_OBJ);
?>
<table class="table table-bordered">
<tr>
<th><center> passport </center></th>
<th><center> quantity</center></th>
</tr>
<?php foreach($people as $donors): ?>
<tr>
<td><center><b><font color="white"><?= $donors->passport_IC; ?></font></b></center></td>
</tr>
<?php endforeach; ?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…