Click here to Skip to main content
15,845,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>Inserting HTML Contents At the End of the Elements in jQuery</title>
<script src=""></script>

    	<tr id="tab1">
	        $con = mysqli_connect("localhost","root","","oatdistribution");
	        $tabsql = "SELECT Name, Status from jan"; 
	        $data = mysqli_query($con,$tabsql);
	        while($row = mysqli_fetch_assoc($data)){
	        	echo "<tr>";
	       		echo "<td>" . $row['Name']."</td>";
	        	echo "<td>" . $row['Status']."</td>";
	        	echo "</tr>";

             John       Delivered
             Richard    Delivered
Name Status  Sam        Delivered
             Allan      Not Delivered
             Michelle   Not Delivered

What I have tried:

I am trying to get the data to be in the table without the piece of code being in the tr tag but the output seems be side by side with the title "Name" and "Status"

How do I go about that?
Updated 25-Mar-21 23:50pm

1 solution

You are appending to the element with ID tab1, which is the header <tr> element.

If you want to append to the <table> element, move the ID to that element:
<table id="tab1">
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900