Hi could someone help me out here. I have a frm that has multiple entries. Each entry has 'artist' 'linl' and 'link text'. link and linktext are optional. My code at the minute needs all to be filled in, if I leave link and link trext blank I get errors.
Here my php code.
<?php
include '../inc/connect.php';
if (isset($_POST['submit'])){
foreach($_REQUEST['artist'] as $aartist){
if ($aartist != ''){
$artist = mysql_real_escape_string($aartist);
foreach($_REQUEST['alink'] as $alink){
if ($alink != ''){
$link = mysql_real_escape_string($alink);
foreach($_REQUEST['alinktext'] as $alinktext){
if ($alinktext != ''){
$linktext = mysql_real_escape_string($alinktext);
}
}
}
}
mysql_query("INSERT INTO artists VALUES ('', '$artist', '$link', '$linktext')");
}
}
}
?>
This is my form
<form class="form1" action="artistadd.php" method="post" enctype="multipart/form-data" name="artist_add_form" id="artist_add_form">
<p><?php for($i=0; $i<8; $i++): ?>
<span class='text'><b>Artist</b></span> <input type=text name="artist[]">
<span class='text'><b>URL</b></span> <input type=text name="alink[]">
<span class='text'><b>Link Text</b></span> <input type=text name="alinktext[]"><br />
<?php endfor; ?></p>
<input type="submit" name="submit" value="Upload Links" />
<input name="submitted_form" type="hidden" name="submitted_form" value="artistss_upload_form" />
</form>
Thanks for looking..................