Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wiele pol tekstowych i zapis do pliku
dublinka
post
Post #1





Grupa: Zarejestrowani
Postów: 594
Pomógł: 66
Dołączył: 22.02.2008
Skąd: Dublin

Ostrzeżenie: (0%)
-----


Generuje wiele pol tekstowych petla i potrzebuje to zapisac do pliku linia po linii poniewaz jedna 'linia' formularza sklada sie z 4 pol.
  1. <div align="center">
  2. <table border="1" width="800" height="179">
  3. <tr>
  4. <td height="60" width="800" align="center" colspan="4">costam</td>
  5. </tr>
  6. <tr><td height="46" width="370" align="center">Name</td>
  7. <td height="46" width="370" align="center">Surname</td>
  8. <td height="46" width="370" align="center">Phone</td>
  9. <td height="46" width="370" align="center">Orgin</td></tr>
  10. <?
  11. for($i=1;$i<=$_POST['wybor1'];$i++)
  12. {
  13. print "<tr><td height=\"46\" width=\"370\" align=\"center\">".$i." <input TYPE=\"text\" name=\"name[]\" maxlength=\"10\"></td>";
  14. print "<td height=\"46\" width=\"370\" align=\"center\"><input TYPE=\"text\" name=\"surname[]\" maxlength=\"10\"></td>";
  15. print "<td height=\"46\" width=\"370\" align=\"center\"><input TYPE=\"text\" name=\"phone[]\" maxlength=\"10\"></td>";
  16. print "<td height=\"46\" width=\"370\" align=\"center\"><input TYPE=\"text\" name=\"orgin[]\" maxlength=\"10\"></td></tr>";
  17. }
  18.  
  19. ?>
  20.  
  21. <tr>
  22. <td height="50" width="800" colspan="4" align="center"><center><input TYPE="submit" value="==== NEXT STEP ===="></center></td>
  23. </tr>
  24. </table>
  25. </div></form>


  1. $_POST['wybor1'] // to poslana z formularza liczba - np. 10


Iteraz mam 10 linni po 4 kazda.

Jak to zapisac linia po linii czyli:

imie||nazwisko||phone||kraj
imie2||nazwisko2||phone2||kraj2

Nigdy nie wiadomo ile tych linii bedzie.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
LeNy
post
Post #2





Grupa: Zarejestrowani
Postów: 102
Pomógł: 4
Dołączył: 17.01.2009

Ostrzeżenie: (0%)
-----


Robiłem na szybko ale działa


  1. <form action="" method="POST">
  2. // tutaj zapętlisz sobie to ile razy chcesz
  3. <input TYPE="text" name="name" maxlength="10">
  4. <input TYPE="text" name="surname" maxlength="10">
  5. <input TYPE="text" name="phone" maxlength="10">
  6. <input TYPE="text" name="orgin" maxlength="10">
  7.  
  8. <input name="submit" type="submit" value="test" />
  9. </form>


  1. <?PHP
  2.  
  3. if(isset($_POST['submit']))
  4. {
  5. foreach($_POST as $type => $value)
  6. {
  7. $result = NULL;
  8. if($type != 'submit')
  9. {
  10. $result .= $value.'||';
  11. }
  12. echo $result; // tutaj robisz zapis do nowej lini
  13. }
  14.  
  15. }
  16.  
  17. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 17:28