/    Sign up×
Community /Pin to ProfileBookmark

Print Multiple Ids column data from one to other table in mysqli

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]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@jasmine381authorJan 11.2020 — &lt;?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' =&gt; $row['cat_name'], 'tenses' =&gt; [$row['tense_name']]];<br/>
} else {<br/>
$tenseinfo[$row['tenid']]['tenses'][] = $row['tense_name'];<br/>
}<br/>
}<br/>
//var_dump($tenseinfo);<br/>
echo '&lt;table&gt;';<br/>
foreach ($tenseinfo as $catid =&gt; $data) {<br/>
echo '&lt;tr&gt;&lt;td&gt;' . $catid . '&lt;/td&gt;';<br/>
echo '&lt;td&gt;' . $data['cat_name'] . '&lt;/td&gt;';<br/>
$tensesimpl = implode(', ', $data['tenses']);<br/>
echo '&lt;td&gt;' . $tensesimpl . '&lt;/td&gt;&lt;/tr&gt;';<br/>
}<br/>
echo '&lt;/table&gt;';<br/>
?&gt;
×

Success!

Help @jasmine381 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...