0
我插入索引使用复选框和预测使用选择选项。我想将索引及其相应的预测插入到数据库中。我的问题是,如果我检查一个站的索引并预测另一个站也插入到数据库中。请帮帮我 !! 我对用户端的PHP代码是这样插入预测对应的复选框到我的sql数据库使用php
<?php
$stn=array(lucknow,delhi,sitapur);
$index=array(226020,110001,261203);
$fct=array(a,b,c);
for ($i=0; $i<sizeof($index); $i++)
{
?>
<input type= "checkbox" name="stn1[]" value="<? echo $index[$i];?>"><strong>
<? echo $stn[$i];?></strong></br>
<select name="forecast[]">
<?php
echo "<option disabled selected> -- Select an option -- </option>";
foreach($fct as $forecast)
{
echo"<option>$forecast</option>";
}
?>
</select>
<?php
}
?
<input type="Submit" value= "Submit" class="style3" name="Submit">
服务器端的PHP代码是这样的
$station1=$_POST['stn1'];
$forecast1=$_POST['forecast'];
if (sizeof($station1)=="0" or sizeof($forecast1)=="0" or sizeof($station1)! =sizeof($forecast1)) {
die('<h1 align= center><font color=red>Either You have not selected station or forecast. </p> !!! Please select station and its corresponding forecast carefully</font><h1>');
} else {
if ($_POST['Submit']=="Submit"){
for ($i=0; $i<sizeof($station1); $i++)
{
// some my sql command to insert data into database
}
}
echo "<h1 align= center><font color=green> Record is inserted successfully</font></h1>";
}
你是指什么意思?这是预测的指标?这是两者之间的关系? –
索引被定义为变量,我试图在我的数据库中存储索引及其相应的预测。 –