Mariius Posted November 30, 2012 Share Posted November 30, 2012 <html> <body> <?php if (isset($_POST["kat_1"])) { echo($_POST['kat_1']); } else { forms(); } function forms() { echo '<form name="form1" method="post" action="">'; for ($i=1; $i<=10; $i++) { echo ' <input type="text" name="kat_".$i." id="category"> <input type="text" name="kai_".$i." id="cost"><br /> '; } echo ' <input type="hidden" name="index" id="index" value="$i"> <input type="submit" name="send" id="send" value="send"> </form> '; } ?> </body> </html> I want to make a page in which there would be "i" amount of forms and then I want to get results of these forms in the first if statement. I am trying to do so, but I don't get any results what so ever. I would be glad to get some tips on this. Thanks. Link to comment https://forums.phpfreaks.com/topic/271420-how-to-get-results-from-i-amount-of-forms/ Share on other sites More sharing options...
mrMarcus Posted November 30, 2012 Share Posted November 30, 2012 Your concatenation was wrong: <input type="text" name="kat_'. $i .'" id="category"> <input type="text" name="kai_'. $i .'" id="cost"><br /> Link to comment https://forums.phpfreaks.com/topic/271420-how-to-get-results-from-i-amount-of-forms/#findComment-1396544 Share on other sites More sharing options...
Mariius Posted November 30, 2012 Author Share Posted November 30, 2012 Your concatenation was wrong: <input type="text" name="kat_'. $i .'" id="category"> <input type="text" name="kai_'. $i .'" id="cost"><br /> Thank you so much Link to comment https://forums.phpfreaks.com/topic/271420-how-to-get-results-from-i-amount-of-forms/#findComment-1396550 Share on other sites More sharing options...
Mariius Posted November 30, 2012 Author Share Posted November 30, 2012 I would appreciate if you could help me once again: this time I am trying to insert values to my sql. $k=1; while($k<=$category[0]) { $baze="INSERT INTO Mine (date, category, cost) VALUES (CURDATE(),$category[$k],$cost[$k])"; $k++; } Here $category[0] is the amount of froms that have been printed out. I get this error: Query was empty Link to comment https://forums.phpfreaks.com/topic/271420-how-to-get-results-from-i-amount-of-forms/#findComment-1396553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.