hello i inserted data in to table A and get IDs from table A to table B in catid column like 1, 2, 3… so i want to print IDs values as per multiple ids on same row ,Here is my table and final output table
[upl-image-preview url=https://www.webdeveloper.com/assets/files/2020-01-11/1578758443-200193-tensess.png]
<?php<br/> $sql = "SELECT t.tense_name, c.tenid, c.cat_name FROM tenses t, tensecategory c WHERE t.pktenseid=c.tenid";<br/> $getcat = mysqli_query($conn, $sql);<br/> $tenseinfo = [];<br/> while ($row = mysqli_fetch_assoc($getcat)) {<br/> if (!isset($tenseinfo[$row['tenid']])) {<br/> $tenseinfo[$row['tenid']] = ['cat_name' => $row['cat_name'], 'tenses' => [$row['tense_name']]];<br/> } else {<br/> $tenseinfo[$row['tenid']]['tenses'][] = $row['tense_name'];<br/> }<br/> }<br/> //var_dump($tenseinfo);<br/> echo '<table>';<br/> foreach ($tenseinfo as $catid => $data) {<br/> echo '<tr><td>' . $catid . '</td>';<br/> echo '<td>' . $data['cat_name'] . '</td>';<br/> $tensesimpl = implode(', ', $data['tenses']);<br/> echo '<td>' . $tensesimpl . '</td></tr>';<br/> }<br/> echo '</table>';<br/> ?>
Help @jasmine381 spread the word by sharing this article on Twitter...