私のコードに問題があります:
$size = count($_POST['tv_id']);
$size = count($_POST['Season']);
$size = count($_POST['EpisodeNumber']);
$size = count($_POST['EpisodeName']);
$i = 0;
while ($i < $size) {
$Season = mysql_real_escape_string($_POST['tv_id'][$i]);
$Season = mysql_real_escape_string($_POST['Season'][$i]);
$EpisodeNumber= mysql_real_escape_string($_POST['EpisodeNumber'][$i]);
$EpisodeName= mysql_real_escape_string($_POST['EpisodeName'][$i]);
$sql="INSERT INTO tvshows SET fk_id = '".$fk_id."', tv_id ='".$tv_id."', Season ='".$Season."', EpisodeNumber='".$EpisodeNumber."', EpisodeName='".$EpisodeName."'";
$query = mysql_query($sql) or die(mysql_error());
}
フォームに入力の 1 つだけを入力して送信を押すと、その 1 つだけでなく、playlist_id と他の列が空白の 16 の空白レコードも送信されます。5列に入力すると、それらが送信されますが、fk_idだけで11個の空白も送信されます
私のテーブルレイアウトは次のようなものです:
echo '<tr>';
echo "<td><input type='hidden' name='tv_id[]' id='tv_id' value='' /></td>";
echo "<td><input type='text' name='Season[]' id='Season[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeNumber[]' id='EpisodeNumber[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeName[]' id='EpisodeName[]' value='' /></td>";
echo '</tr>';
echo '<tr>';
echo "<td><input type='hidden' name='tv_id[]' id='tv_id' value='' /></td>";
echo "<td><input type='text' name='Season[]' id='Season[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeNumber[]' id='EpisodeNumber[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeName[]' id='EpisodeName[]' value='' /></td>";
echo '</tr>';
echo '<tr>';
echo "<td><input type='hidden' name='tv_id[]' id='tv_id' value='' /></td>";
echo "<td><input type='text' name='Season[]' id='Season[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeNumber[]' id='EpisodeNumber[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeName[]' id='EpisodeName[]' value='' /></td>";
echo '</tr>';
echo '<tr>';
echo "<td><input type='hidden' name='tv_id[]' id='tv_id' value='' /></td>";
echo "<td><input type='text' name='Season[]' id='Season[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeNumber[]' id='EpisodeNumber[]' value='' /></td>";
echo "<td><input type='text' name='EpisodeName[]' id='EpisodeName[]' value='' /></td>";
echo '</tr>';
さらに約10分間続けます。