<?php
require_once 'Conn.php';
$db->query("SET NAMES utf8");
$sql = "SELECT categoryid,NAME,descn,Image FROM category;";
$result = $db->query($sql);
if ($result->num_rows >= 1) {
echo "<div id=\"main\">";
echo "<table width=80% align=center>";
$i = 0;
while ($row = $result->fetch_assoc()) {
$temp = "<td align=center><a href=\"Products.php?cateid=" . $row["categoryid"] . "\"><img src='Images\\" . $row['Image'] . "' height=150px width=100px></a><br/>" . $row["NAME"] . "</td>";
$i ++;
if (($i - 1) % 4 == 0) {
echo "<tr>" . $temp;
} elseif ($i % 4 == 0) {
echo $temp . "</tr>";
} else {
echo $temp;
}
}
echo "</table>";
echo "</div>";
}
else {
echo "<div style='color:red;margin-top:50px;'>没有查到书籍类别内容!</div>";
}
$result->close();
$db->close();
?>
尝试:
1.我搜索过许多网站,没有发现有效的解决方法
2.曾经放弃phpstorm去使用学校机房里的eclipse2019和wampserver去做作业,但也解决不了问题
3.尝试放弃使用phpmyadmin转而使用MySQL连接phpstorm,发现一些新问题:
(1).学校教的东西不实用,没有教会我们ssh方面的知识,我也不知道如何写参数配置数据源
(2).phpstorm虽然可以执行SQL语句,但是console报错
(3).表格无法查看,点击查看表格出现
(com.intellij.execution.ExecutionException: SSH: net.schmizz.sshj.transport.TransportException: Server closed connection during identification exchange)报错
4.想放弃php,毕竟老师不会教,技能学不会,公司用不着,工作找不到,未来没前途
希望结果:
1.希望phpstorm可以连接并使用数据库表格,$db变量不报错并正常连接
2.或者用phpmyadmin正常连接phpstorm并引用数据