Dzint Posted April 6, 2009 Report Share Posted April 6, 2009 Sveiki, Kā lai pareizi savācu POST datus no dinamiski radītiem inputiem forma kautkā šādi: <input type="text" name="date[]"><input type="text" name="zina[]"> <input type="text" name="date[]"><input type="text" name="zina[]"> <input type="text" name="date[]"><input type="text" name="zina[]"> u.t.t Vajadzētu izveidot N insertus tabulā INSERT INTO tabe ('date', 'zina') VALUES ('text', 'text'); Quote Link to comment Share on other sites More sharing options...
Klez Posted April 6, 2009 Report Share Posted April 6, 2009 (edited) uztaisi print_r($_POST) un ja kko saproti no masīviem tad gan jau ka sapratīsi kur ir tavi dati .. + vēl paskaties par cikliem ... foreach tavā gadījumā Edited April 6, 2009 by Klez Quote Link to comment Share on other sites More sharing options...
Dzint Posted April 6, 2009 Author Report Share Posted April 6, 2009 uztaisi print_r($_POST) un ja kko saproti no masīviem tad gan jau ka sapratīsi kur ir tavi dati .. + vēl paskaties par cikliem ... foreach tavā gadījumā Ar vienu lauku jau butu vienkārši foreach($_POST['date'] as $key) echo $key; bet vairākiem Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted April 6, 2009 Report Share Posted April 6, 2009 Viņiem indeksi vienādiem laukiem ir vienādi: tā ka vari kaut vai for($x=0;$x<sizeof($_POST['date']);$x++){ echo $x . $_POST['date'][$x] . $_POST['zina'][$x] } Quote Link to comment Share on other sites More sharing options...
marcis Posted April 6, 2009 Report Share Posted April 6, 2009 $insert = array(); foreach($_POST['date'] as $key=>$value){ $insert[] = "('".mysql_real_escape_string($value)."','".mysql_real_escape_string($_POST['zina'][$key])."')"; } if(!empty($insert)){ mysql_query("UPDATE `tabula` SET (date,zina) VALUES ".implode(", ",$insert)); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.