I'm sorry if the questions is a bit confusing, tried to make it as clear as possible.
Basically, I have this code:
for($i = 0;$i < 5;$i++)
{
$query = mysql_query("INSERT INTO words (lecture, pol, ukr) VALUES ($lecture, $pol_text[$i], $ukr_text[$i])", $db) or die("Data not inserted");
}
And I want it to insert 5 elements of 2 arrays - $pol_text and $ukr_text, but not to do it manually, is there any way I could do it somewhat automatic?
Thank you!
Edit: Not quite sure if this will help, but submitting more code, that checks if submit is pressed:
<?
if (isset($_POST['submit']))
{
if (isset($_POST['pol_text'])){$pol_text = $_POST['pol_text'];}
if (isset($_POST['ukr_text'])){$ukr_text = $_POST['ukr_text'];}
if (isset($_POST['lecture'])){$lecture = $_POST['lecture'];}
for($i = 0;$i < 5;$i++)
{
$query = mysql_query("INSERT INTO words (lecture, pol, ukr) VALUES ($lecture, $pol_text[$i], $ukr_text[$i])", $db) or die("Data not inserted");
}
/* DATA NOT INSERTED BECAUSE CAN'T BE WITH $I INSIDE QUERY?!?!?!?'*/
unset($_POST['submit']);
}
?>
name=pol_text[]andname=pol_text[]respectively. I'm submitting a form, and thinking on how can I automate this. I suppose I can just write it all manually 5 times, but for future reference, what if I'll have more than 5 fields, I'd like to know possible ways to automate this, thanks!