我的脚本需要你的帮助。我正在尝试将值插入 mysql,同时输入 $row['senatorial'] 和 $constituencys。下面的 coe 是我正在努力工作,但它不起作用。我在屏幕上没有显示任何错误,也没有任何内容输入到数据库中。请问我哪里错了
<?php
if (isset($_POST['action']) && $_POST['action'] == "submit") {
$state = mysql_real_escape_string(trim($_POST['state']));
$query = mysql_query("SELECT senatorial
FROM state
WHERE state = '".$state."'") or die (mysql_error());
$duplicates = mysql_num_rows($query);
if (isset($_POST['constituency']) && $_POST['action'] == "create") {
$constituencys = $_POST['constituency'];
foreach($constituencys as $constituency) {
$query = "
INSERT INTO `state` (
`state_id`,
`state`,
`senatorial`
`constituency`
) VALUES (
NULL,
'{$state}',
'{$row['senatorial']}',
'" . mysql_real_escape_string(trim($constituency)) . "'
)
";
mysql_query($query) or die (mysql_error());
}
} ?>
<form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="post">
<?php
while($row=mysql_fetch_assoc($query)){
echo strtoupper($row['senatorial']) ;?>
<input type='text' name='constituency[]' title='Federal Constituency' />
<?php } ;?>
<input type="hidden" name="create" value="create" />
<input type='submit' name='create' value='Create' />
</form>
<?php } ?>
<h2>Select State To show Senatorial Districts</h2>
<form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="post">
State:<select name="state" title='State' class='OpenInput_Select'>
<option value =""> </option>
<option value ="state1">state1</option></select>
<input type="hidden" name="action" value="submit" />
<input type='submit' name='submit' value='SHOW' />
</form>