当尝试检索从下拉列表中选择的数据时,收到此错误“使用未定义的常量selectedClientName-假定为'selectedClientName'”。
它说错误在这行代码的第47行上
if (isset($_POST[selectedClientName])) {
在下面的代码中。
<?php
$result=mysqli_query($conn, "SELECT clientName FROM clients");
echo "<left>";
echo "<h1>Hotel Data Collection</h1>";
echo "<hr/>";
echo "<p> Choose Client: </p>";
echo "<select name='selectedClientName'>";
echo "<option>--Clients--</option>";
while ($row=mysqli_fetch_array($result)) {
$cn = $row['clientName'];
echo "<option>$cn</option>";
}
echo "</select>";
echo "</center>";
?>
<button type="submit" name="client-submit">Submit</button>
</form>
</section>
</div>
<?php
if (isset($_POST[selectedClientName])) {
$cn = $_POST['cn'];
$query = "SELECT * FROM savedclientdata WHERE array_column ['clientName'] = $cn";
$result = mysqli_query($conn, $query) or die('error getting data');
}
?>
我的最终目标是让用户选择一个客户名称,然后显示与该客户相对应的数据。