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>";
}
你是指什麼意思?這是預測的指標?這是兩者之間的關係? –
索引被定義爲變量,我試圖在我的數據庫中存儲索引及其相應的預測。 –