我有 2 张桌子
domain_info 和 tb2
我的表格运行良好并将数据输入数据库
这是我页面的顶部
<?php
$action = isset($_POST['action']) ? $_POST['action'] : "";
if($action=='create'){
//include database connection
include 'db_connect.php';
//write query
$query = "insert into domains_info
set
domain = '".$mysqli->real_escape_string($_POST['domain'])."',
domain_account = '".$mysqli->real_escape_string($_POST['domain_account'])."',
renew_date = '".$mysqli->real_escape_string($_POST['renew_date'])."'";
if( $mysqli->query($query) ) {
//if saving success
header("Location:domains.php");
}else{
echo "Database Error: Unable to create record.";
}
$mysqli->close();
}
这是表格
<select id="domain_account" name="domain_account" class="txtBox">
<option value="">-select-</option>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
我尝试并像这样更改了我的页面顶部
<?php
$action = isset($_POST['action']) ? $_POST['action'] : "";
if($action=='create'){
//include database connection
include 'db_connect.php';
//write query
$query = "insert into domains_info
set
domain = '".$mysqli->real_escape_string($_POST['domain'])."',
domain_account = '".$mysqli->real_escape_string($_POST['domain_account'])."',
renew_date = '".$mysqli->real_escape_string($_POST['renew_date'])."'";
if( $mysqli->query($query) ) {
//if saving success
header("Location:domains.php");
}else{
echo "Database Error: Unable to create record.";
}
$mysqli->close();
}
$query = "select id, data
from tb2
where id='".$mysqli->real_escape_string($_REQUEST['id'])."'
limit 0,1";
$result = $mysqli->query( $query );
$row = $result->fetch_assoc();
$id = $row['id'];
$data = $row['data'];
并更新了我的表格
<select id="domain_account" name="domain_account" class="txtBox">
<option value="">-select-</option>
<option value="<?php echo$data; ?>"><?php echo$data; ?></option>
</select>
正如你所知道的,我对此很陌生,而且它不起作用。
抱歉,我没有解释我想要实现的目标,我正在尝试显示一个包含数据库数据的下拉表单。