Showing Mysql Rows Content In Html Table Using Php
I'm new here and I have a question, I looked for the solution everywhere and I still cant manage to solve this. I want to show the results of the SELECT statement (in php) in a tab
Solution 1:
In this line
echo "<table border='2px'><tr><td>cod</td><td>nmbre</td><td>drccn</td</tr>";
The final </td>
is missing a >
Solution 2:
Everything is perfect in your script if you are sure about your mysql details. Please check your js files getting included in script.
<scriptsrc="http://code.jquery.com/jquery-2.1.4.min.js"></script>
Solution 3:
I removed jquery.js and inserted another script at head. It worked for me. I connected it to localhost. check it.
main.html
<html><head><metacharset="UTF-8"/><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script><scriptsrc="select.js"type="text/javascript"></script></head><body><buttonid="button"> Mostrar </button><br><inputtype="text"id="id" /><divid="content"></div></body></html>
select.js
$(document).ready(function(){
$("#button").click(function () {
functionshow_all() {
$.ajax({
type: "POST",
url: "select.php",
data:{action:"showroom"},
success: function (data) {
$("#id").hide();
$("#content").html(data);
}
});
}
show_all();
});
});
select.php
<?php$link=mysqli_connect("localhost", "root","","manishYii");
if (mysqli_connect_errno() )
echo"Fallo en la conexion con mysql" .mysqli_connect_error();
$action=$_POST["action"];
if ($action=="showroom") {
$query = "SELECT FirstName, LastName, EmailID from members";
$show = mysqli_query($link, $query) ordie ("error");
echo"<table border='2px'><tr><td>cod</td><td>nmbre</td><td>drccn</td</tr>";
while ($row = mysqli_fetch_array($show)) {
echo"<tr><td>" .$row['FirstName']."</td><td>".$row['LastName']."</td><td>".$row['EmailID']."</td></tr>";
}
echo"</table>";
}
?>
Solution 4:
try this
while ($row = mysqli_fetch_assoc($show)) {
echo"<tr><td>" .$row['cod']."</td><td>".$row['nmbre']."</td><td>".$row['drccn']."</td></tr>";
}
or
while ($row = mysqli_fetch_assoc($show)) {
echo"<tr><td>" .$row['0']."</td><td>".$row['1']."</td><td>".$row['2']."</td></tr>";
}
Post a Comment for "Showing Mysql Rows Content In Html Table Using Php"