Hi, I need help here.
I have a for with multiple text inputs. input1 is link, input2 is description.
This is repeated a number of time.
Each link and description is one record, but I cant igure out how to add them to mysql as such.
If I fill in 2 link/desription it adds 4 records to mysql so I have 2 of each!
Can anyone help me out her?
Here is my code.
<form class="form1" action="linksaddform.php" method="post" enctype="multipart/form-data" name="links_upload_form" id="links_upload_form" style="margin-bottom:0px;">
<p><span class='text'><b>Link</b></span> <input type=text name="alink[0]">
<span class='text'><b>Description</b></span> <input type=text name="aname[0]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[1]">
<span class='text'><b>Description</b></span> <input type=text name="aname[1]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[2]">
<span class='text'><b>Description</b></span> <input type=text name="aname[2]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[3]">
<span class='text'><b>Description</b></span> <input type=text name="aname[3]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[4]">
<span class='text'><b>Description</b></span> <input type=text name="aname[4]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[5]">
<span class='text'><b>Description</b></span> <input type=text name="aname[5]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[6]">
<span class='text'><b>Description</b></span> <input type=text name="aname[6]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[7]">
<span class='text'><b>Description</b></span> <input type=text name="aname[7]"><br />
<span class='text'><b>Link</b></span> <input type=text name="alink[8]">
<span class='text'><b>Description</b></span> <input type=text name="aname[8]"></p>
<input type="submit" name="submit" value="Upload Links" />
<input name="submitted_form" type="hidden" id="submitted_form" value="links_upload_form" />
</form>
<?php
include '../inc/connect.php';
if (isset($_POST['submit'])){
foreach($_REQUEST['alink'] as $alink){
if (($alink != ''){
foreach($_REQUEST['aname'] as $aname ){
if ($aname != ''){
mysql_query("INSERT INTO links VALUES ('', '$alink', '$aname')");
}
}
}
}
}
?>
Thanks for looking.................