I want to convert this bellow two MySQL query(specially second query) in PostgreSQL query.because I want to use this bellow query for PostgreSQL database.So how can i write this bellow query in PostgreSQL.So that this bellow query support PostgreSQL Database.
<?php
$data = [];
$branchs = [];
$query=mysqli_query($con,"SELECT DISTINCT branchcode FROM brackinfo2 WHERE event_id BETWEEN 71 AND 75");
while($values=mysqli_fetch_array($query)){
$branchs[] = $values['branchcode'];
}
$query=mysqli_query($con,"SELECT CONCAT(section,'.', sub_sec_id) AS si, GROUP_CONCAT (CONCAT(branchcode,':',question_point)) as brands, section, sub_sec_id, point as fullmark FROM brackinfo2 WHERE event_id BETWEEN 71 AND 75 GROUP BY branchcode,si");
while($values=mysqli_fetch_array($query)){
$data[$values['si']]['fullmark'] = $values['fullmark'];
$data[$values['si']]['section'] = $values['section'];
$tmp = explode(",", $values['brands']);
foreach ($tmp as $key => $value) {
$tmp2 = explode(":", $value);
$data[$values['si']]['branchs'][$tmp2[0]] = $tmp2[1];
}
}
?>
<table>
<thead>
<tr>
<th>SI</th>
<th>Full Marks</th>
<th>Section & Indicator Name</th>
<?php
foreach ($branchs as $branch) {
echo "<th> Branch Name<br>($branch)</th>";
}?>
</tr>
</thead>
<tbody>
<?php
foreach ($data as $si => $info)
{
echo "<tr>";
echo "<td>$si</td>";
echo "<td>{$info['fullmark']} </td>";
echo "<td>{$info['section']} </td>";
foreach( $branchs as $branch)
{
if (isset($info['branchs'][$branch])) {
echo "<td>{$info['branchs'][$branch]}</td>";
} else {
echo "<td></td>";
}
}
echo "</tr>";
}
?>
</tbody>
</table>