我想知道究竟是什么阻止此代码显示item_name,item_weight,item_value,item_description。所有这些信息都可以正确存储到phpadmin中。当我去显示表时,它只显示表的标题而不是内容。
<?php
$connection = mysqli_connect("localhost", "*******", "******");
//select database.
mysql_select_db('brandind_dnd');
//gathers all info from 'items' in sql and stores into variable sql.
$sql="SELECT * FROM items";
//inserted stored_items variable into mysql_fetch_assoc() in while loop
below.
$stored_items = mysql_query($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Item</title>
<style>
</style>
</head>
<body>
<div class="additem">
<h1>Add Item</h1>
<form action="insert.php" method="post">
<p>
<label for="itemName">Name:</label>
<input type="text" name="item_name" id="itemName">
</p>
<p>
<label for="itemWeight">Weight:</label>
<input type="text" name="item_weight" id="itemWeight">
</p>
<p>
<label for="itemValue">Value:</label>
<input type="text" name="item_value" id="itemValue">
</p>
<p>
<label for="itemDesc">Description:</label>
<input type="text" name="item_desc" id="itemDesc">
</p>
<input type="image" id="inventory" name="submit" src="inventory_image.png"
border="0" alt="Submit" /></a><br><br>
</div>
<table maxwidth="600" border="1" cellpadding="1" cellspacing="1">
<tr>
<th id="table_col_1">Item</th>
<th id="table_col_2">Weight</th>
<th id="table_col_3">Value</th>
<th id="table_col_4">Description</th>
<tr>
<?php
($item=mysql_fetch_assoc($stored_items)){
echo "<tr>";
echo "<td>".$item['item_name']."</td>";
echo "<td>".$item['item_weight']."</td>";
echo "<td>".$item['item_value']."</td>";
echo "<td>".$item['item_description']."</td>";
echo "</tr>";
}//end while
?>'
</table>
</form>
</body>
</html>