嗨,我已经做了一些AJAX
PHP&MySQL 排序,它给了我结果,如下面的代码所示,我的问题是如何将 $result 带入 html divs
。
请帮忙
使用的 PHP 代码
<?php
$q=$_GET["q"];
$con = mysql_connect('localhost', 'root', '');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("security_software", $con);
$sql="SELECT * FROM internet_security ORDER by '".$q."' DESC" ;
$result = mysql_query($sql);
echo "<table border='1'>
<tr>
<th>id</th>
<th>title</th>
<th>image</th>
<th>description</th>
<th>rating</th>
<th>download</th>
<th>buy</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['image'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['rating'] . "</td>";
echo "<td>" . $row['download'] . "</td>";
echo "<td>" . $row['buy'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
我想要这些 HTML Div 的结果
<div class="category-container">
<div class="category-image"></div>
<div class="category-link"><a href="#">#</a></div>
<div class="category-desc"><p>#</p> </div>
<div class="rating5" >Editors' rating: </div>
<div class="category-download-btn"><a href="#">Download </a></div><
<div class="category-buy-btn"><a href="#">Buy</a></div>
</div>