<form id="track" name="track" method="post" action="tester.php">
<h2>Track your shipment Here</h2>
<p><label> Tracking Reference:
<input type="text" id="reference" name="reference" value="" maxlength="40" required="required" /></label></p>
<div class="button_holder">
<p> <input type="submit" id="track" value="Track Now" maxlength="40" required="required" /></label>
</label></p>
</div>
我的php代码是:
<?php
$ref = mysql_real_escape_string($_POST['reference']);
// conmnecting to the database
if(isset($ref)){
$connection = mysql_connect('localhost', 'root', 'wisdom');
mysql_select_db('gday');
$query = "SELECT * FROM shipment WHERE id = '".$ref."' ";
$row = mysql_query($query);
echo "<table border=\"1\"; width='550px'>"; // start a table tag in the HTML
//Creates a loop to loop through results
echo "<tr><td>" . $row['id'] . "</td><td>" . $row['ship_type'] . "</td><td>" . $row['ship_ref'] . "</td><td>" . $row['ship_date'] . "</td><td>" . $row['ship_weight'] . "</td><td>" . $row['expected_delivery'] . "</td></tr>" . $row['ship_country'] . "</td></tr>" . $row['ship_state'] . "</td></tr>" . $row['ship_city'] . "</td></tr>" . $row['ship_zip'] . "</td></tr>" . $row['remark'] . "</td></tr>";
echo "</table>"; //Close the table in HTML
mysql_close(); //Make sure to close out the database connection
}
else{echo " Enter a valid Reference Number";
exit;}
?>
现在,我的主要问题是:以下代码仅输出没有插入任何信息的表,请问可以做些什么来确保行填充了从数据库中检索到的数据? 感谢
答案 0 :(得分:0)
获取提取功能.......
像这样改变:
$res= mysql_query($query);
$row=mysql_fetch_assoc($res);
mysqli_
函数已弃用,不再使用它们。请改用MySQLi或PDO库。