gpt4 book ai didi

php - 如何从 mysql 将值回显到选项表单中

转载 作者:行者123 更新时间:2023-11-29 07:19:03 25 4
gpt4 key购买 nike

<分区>

我的服务页面中有两个下拉/选择输入,一个用于服务类型,另一个是每项服务的价格,每项服务均从 mysql 发送如何使价格值自动更改为连接到服务类型的任何数据想要什么例如选择,写一本书它会显示它从 db 的价格

当我用 jquery 尝试它时,我不能给出任何选项值,因为它都来自数据库

<label style="margin-left:20px; padding: 0 20px;
margin-bottom: 39px;">what we do for you </label><select name="topic" Required="Required">
<?php
// Make the connection:
$connection = mysqli_connect ('localhost', '#', '#', '#');
// If no connection could be made, trigger an error:
if ($connection->connect_error)
{
die("Database selection failed: " . $connection->connect_error);
}
# Set encoding to match PHP script encoding.
mysqli_set_charset($connection, 'utf8');
$query = "SELECT * FROM services";
$select_service = mysql_query($query);
while ($row = @mysql_fetch_assoc($select_service)) {
echo "<option value=\"".$row['id']."\">".$row['title']."</option>\n ";
}
?>
</select><br>

<label style=" margin-left: 136px;
margin-bottom: 30px; padding: 0 20px;">price</label><select disabled name="topic" Required="Required">
<?php
// Make the connection:
$connection = mysqli_connect ('localhost', '#', '#', '#');
// If no connection could be made, trigger an error:
if ($connection->connect_error)
{
die("Database selection failed: " . $connection->connect_error);
}
# Set encoding to match PHP script encoding.
mysqli_set_charset($connection, 'utf8');
$query = "SELECT * FROM services";
$select_service = mysql_query($query);
while ($row = @mysql_fetch_assoc($select_service)) {
$service_prise = $row['prise'];
$service_content = $row['description'];
echo "<option >".$row['description']."</option>\n ";
}
?>
</select>
<br>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com