If I am populating a list with MySQL data using the following:
HTML
<ul id="first_column"></ul>
<br>
<ul id="second_column"></ul>
JQUERY/AJAX
$(document).ready(function() {
$.ajax({
url: "filename.php",
success:
function(data){
$("#first_column").html(data);
}
})
})
PHP
$conn = OpenCon();
$sql = "SELECT first_column FROM table";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
while ($row = mysqli_fetch_assoc($result)) {
echo '<li>' .$row['first']. '</li>';
}
}
How can I add a second SQL query (SELECT second_column FROM table) to the PHP and output it to <ul id="second_column"></ul> from the returned AJAX data? I think I have to use arrays and json, but I am struggling to figure it out.