I have a query that gets some data that I need to display on my webpage. Here is my query:
$sql1 = "SELECT CAST([Series] AS INT) AS Series
,[Master Supplier Title]
,[Fund Name]
,CAST([Agreement_ID] AS INT) AS Agreement_ID
,CAST([Tier_ID] AS INT) AS Tier_ID
,[Retro_to_1]
,CAST([Payments per Year] AS INT) AS [Payments per Year]
,[Condition Unit of Measure]
,CAST([Condition Minimum] AS INT) AS [Condition Minimum]
,CAST([Condition Maximum] AS INT) AS [Condition Maximum]
,CAST([Incentive Multiplier] AS DEC(5,4)) AS [Incentive Multiplier]
FROM [Test].[dbo].[vExample]
WHERE [Master Supplier Title] = '$supp' AND [Series] = 1 AND [Fund Name] = '400P' AND [Agreement_ID] = 2
ORDER BY [Master Supplier Title]";
I am then using this chunk of code to display the needed results:
<?php foreach ($pdo->query($sql1) as $supp11) { ?>
<label>Agreement ID:</label><input value="<?php echo $supp11['Agreement_ID'];?>" readonly><br><br><br>
<table>
<tr>
<thead>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</thead>
</tr>
<?php foreach ($pdo->query($sql1) as $supp22) { ?>
<tr>
<tbody>
<td><?php echo $supp22['Tier_ID'];?></td>
<td><?php echo $supp22['Incentive Multiplier'];?></td>
<td><?php echo $supp22['Condition Minimum'];?></td>
<td><?php echo $supp22['Condition Maximum'];?></td>
<td><?php echo $supp22['Condition Unit of Measure'];?></td>
<td><?php echo $supp22['Retro_to_1'];?></td>
<td><?php echo $supp22['Payments per Year'];?></td>
</tbody>
</tr>
<?php } ?>
</table>
<?php } ?>
The variable $supp
that you see is the value that I get from my dropdown selection that I have in some previous code.
Whenever, I make a dropdown selection, it displays the correct data. However, I only need it to display in a table one time. For example, a selection may be in multiple rows of the database. So whenever it is displaying the results in a table, it is displaying the results in a table the number of times that the dropdown selection is seen in the database. So, if the value in my $supp
variable is seen 8 times in the database, I only need that info (8 rows) in a table ONE TIME. Not eight different times like I am currently getting.
How can I fix this problem?