我正在尝试在 HTML 表中显示数据库中的数据,我想在警报框中显示此 html 表,现在它在警报框内显示数据但不像 html 表那样显示,现在我的警报框显示像这个:
我想以 HTML 表格格式显示它。任何人都可以指导我如何做到这一点,
这是我的代码:
阿贾克斯
$(document).ready(function() {
$("#display").dblclick(function() {
$.ajax({ //create an ajax request to load_page.php
type: "GET",
url: "supplierprice/retrieve.php",
dataType: "html", //expect html to be returned
success: function(response){
$("#responsecontainer").html(response);
alert(response);
}
});
});
});
HTML
<td><input type="button" id="display" value="" /></td>
Retrieve.php
:
include"config.php";
$result=mysql_query("select * from supplierpricehistory");
echo "<table border='1' >
<tr>
<td align=center> <b>supplier</b></td>
<td align=center><b>country</b></td>
<td align=center><b>networkname</b></td>
<td align=center><b>mcc</b></td></td>
<td align=center><b>mnc</b></td>
<td align=center><b>newprice</b></td>
<td align=center><b>oldprice</b></td>
<td align=center><b>status</b></td>
<td align=center><b>date</b></td>
<td align=center><b>user</b></td>";
while($data = mysql_fetch_row($result))
{
echo "<tr>";
echo "<td align=center>$data[1]</td>";
echo "<td align=center>$data[2]</td>";
echo "<td align=center>$data[3]</td>";
echo "<td align=center>$data[4]</td>";
echo "<td align=center>$data[5]</td>";
echo "<td align=center>$data[6]</td>";
echo "<td align=center>$data[7]</td>";
echo "<td align=center>$data[8]</td>";
echo "<td align=center>$data[9]</td>";
echo "<td align=center>$data[10]</td>";
echo "</tr>";
}
echo "</table>";