Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Tablice i uklad danych
DannyM
post
Post #1





Grupa: Zarejestrowani
Postów: 507
Pomógł: 2
Dołączył: 30.10.2003
Skąd: Poznań

Ostrzeżenie: (10%)
X----


mam taka tablice
Array
(
[name] => Array
(
[0] => Marta
[1] => Jak
)

[nazwisko] => Array
(
[0] => Warta
[1] => Kowalski
)

[email] => Array
(
[0] => marti@ppsdfsd.pl
[1] => kowal@map.pl
)

[password] => Array
(
[0] => chauyec66
[1] => 456tre
)

[Submit] => Zamawiam
)

  1. foreach ($_POST as $klucz => $tablica ) {
  2.  
  3. foreach ($tablica as $nr_wiersza => $wartosc )
  4. echo 'ID: '.$nr_wiersza.' =:'.$wartosc;
  5. }
  6. print "<pre>";
  7. print_r($_POST);
  8. print "</pre>";


Jak przypisac imie do nazwiska itd
Dodatkowo mam Warning: Invalid argument supplied for foreach() in " foreach ($tablica as $nr_wiersza => $wartosc ) "
Dopiero zaczynam z tablicami wiec prosze o wyrozumialosc

Ten post edytował DannyM 17.12.2009, 16:21:18
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
piotrekkr
post
Post #2





Grupa: Zarejestrowani
Postów: 386
Pomógł: 25
Dołączył: 28.09.2005

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


  1. <table border="1" cellspacing="1" cellpadding="0">
  2. <tr>
  3. <td>Imię</td>
  4. <td>Nazwisko</td>
  5. <td>E-mail</td>
  6. <td>Hasło</td>
  7. </tr>
  8. <?php
  9. $srcArray = $_POST;
  10. $destArray = array();
  11. unset($srcArray['Submit']);
  12. foreach($srcArray as $key => $val){
  13. foreach($val as $personId => $personValue){
  14. $destArray[$personId][$key] = $personValue;
  15. }
  16. }
  17. foreach($destArray as $person){
  18. echo '<tr><td>'.implode('</td><td>', $person).'</td></tr>';
  19. }
  20. </table>


Ten post edytował piotrekkr 17.12.2009, 17:35:30
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: 1.01.2026 - 16:38