使用以下代码,我只将第一行放入数据库。看了很多例子,但我仍然看不出我哪里出错了。
// one box for each //
<input class="bginput" name="album_name[]" size="30" type="text">
<imput type="submit" Value="submit">
<?PHP
foreach($_POST['artist_id'] as $row=>$val) {
$artist_id = mysql_real_escape_string($val);
$album_name = mysql_real_escape_string($_POST['album_name'][$row]);
$image_album_id = mysql_real_escape_string($_POST['image_album_id'][$row]);
$track = mysql_real_escape_string($_POST['track'][$row]);
$song_name = mysql_real_escape_string($_POST['song_name'][$row]);
$duration = mysql_real_escape_string($_POST['duration'][$row]);
$sql = mysql_query("INSERT INTO songs (`image_album_id`, `member_id`, `artist_id`, `album_name`, `track`, `song_name`, `duration`, `timestamp`)
VALUES ('$image_album_id', '".$_SESSION['member_id']."','$artist_id','$album_name', '$track', '$song_name', '$duration', UNIX_TIMESTAMP() )") or die(mysql_error());
header ('Location: song_details_add.php?success');
exit();
?>
谢谢。