/    Sign up×
Community /Pin to ProfileBookmark

__(Added `[code]…[/code]` tags ~ MOD)__

my code is only displaying one record from my comments table `

[code]
<?php

$sql =” SELECT * FROM `comments` “;
$result = mysqli_query($db, $sql);

while($row = mysqli_fetch_assoc($result)){
$comment_id = $row[‘comment_id’];
$comment_company_id = $row[‘comment_company_id’];
$comment_name = $row[‘comment_name’];
$comment_content = $row[‘comment_content’];
$comment_email = $row[‘comment_email’];
$comment_status = $row[‘comment_status’];
$comment_date = $row[‘comment_date’];

echo “<tr>”;
echo “<td>$comment_id </td>”;
echo “<td>$comment_name </td>”;
echo “<td>$comment_content</td>”;
echo “<td>$comment_email</td>”;
echo “<td>$comment_status </td>”;

$sql =” SELECT * FROM `waste_collection_companies_info_table` WHERE `company_id`=’$comment_company_id'”;
$result = mysqli_query($db, $sql);

while($row = mysqli_fetch_assoc($result)){
$company_id = $row[‘company_id’];
$company_name = $row[‘company_name’];

echo “<td><a href =’../post.php?p_id=$company_id’>$company_name</a></td>”;
}

echo “<td>$comment_date </td>”;

echo “<td><a href=’companies.php?source=edit_companies&p_id=’>approve</a></td>”;
echo “<td><a href=’companies.php?delete=’>disapprove</a></td>”;
echo “<td><a href=’companies.php?delete=’>delete</a></td>”;

echo “</tr>”;
}

?>

</tbody>
</table>

<?php
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 20.2020 — The query on waste_collection_companies_info_table inside of your first while() loop is overwriting $result and $row. You need to use different names for that inner query/loop.
Copy linkTweet thisAlerts:
@passyauthorApr 21.2020 — thanks it works now
Copy linkTweet thisAlerts:
@yigoxamApr 23.2020 — Hi, buddy[,](https://vidmate.onl/) thanks a lot was stuck at a similar place. it did work.

Regards[,](https://plex.software/)

Y. Smith
×

Success!

Help @passy 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.28,
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,
)...