Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Jak rozwiazać taki problem
rad11
post 20.10.2014, 08:20:10
Post #1





Grupa: Zarejestrowani
Postów: 1 270
Pomógł: 184
Dołączył: 7.10.2012
Skąd: Warszawa

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


Chcialbym w kazdym data-title umiescic odpowiadajaca nazwe kolumny tylko poprzez petle tak jak w tablicy columns i nie mam pomyslu jak to rozwiazac jakies pomysly?

  1. <table class="table display">
  2. <thead>
  3. <tr>
  4. <?php foreach($columns as $col): ?>
  5. <th><?php echo ucfirst($col->Field); ?></th>
  6. <?php endforeach;?>
  7. <th>Actions</th>
  8. </tr>
  9. </thead>
  10. <tbody>
  11. @foreach($array as $key => $value)
  12. <tr>
  13. <td style="word-break:break-all;" class="rows" data-title="ID">{{ $value->id }}</td>
  14. <td style="word-break:break-all;" class="rows" data-title="City">{{ $value->city }}</td>
  15. <td style="word-break:break-all;" class="rows" data-title="Powiat">{{ $value->powiat }}</td>
  16. <td style="word-break:break-all;" class="rows" data-title="Lat">{{ $value->lat }}</td>
  17. <td style="word-break:break-all;" class="rows" data-title="Lng">{{ $value->lng }}</td>
  18. <td style="word-break:break-all;" class="rows" data-title="Count">{{ $value->count }}</td>
  19. <td style="word-break:break-all;" class="created rows" data-title="Created">{{ $value->created_at }}</td>
  20. <td style="word-break:break-all;" class="updated rows" data-title="Updated">{{ $value->updated_at }}</td>
  21. <td style="word-break:break-all;" data-title="Actions">
  22. {{ Form::open(array('url' => $table_name . '/' . $value->id)) }}
  23. {{ Form::hidden('_method', 'DELETE') }}
  24. {{ Form::submit('Delete', array('class' => 'btn btn-danger')) }}
  25. {{ Form::close() }}
  26. <a class="btn btn-small btn-success rows" href="{{ URL::to($table_name . '/' . $value->id) }}">Show</a><br/>
  27. <a class="btn btn-small btn-info rows" href="{{ URL::to($table_name . '/' . $value->id . '/edit') }}">Edit</a><br/>
  28. </td>
  29. </tr>
  30. @endforeach
  31. </tbody>
  32. </table>
Go to the top of the page
+Quote Post
Micchaleq
post 21.10.2014, 13:29:13
Post #2





Grupa: Zarejestrowani
Postów: 186
Pomógł: 4
Dołączył: 13.10.2009

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


Cześć,

Dla mnie jest to troche niezrozumiałe. Musisz odkryć jaką zależność ma $column z $array, albo pokazać nam to co zawierają te dwie tablice.
Wtedy albo jakoś całe drzewo zbudować z $column albo z $array. Ewentualnie przed wygenerowanie dopisać do $array taką zależnośc i odpowiednio ją wyświetlać.

Pozdrawiam


--------------------
Go to the top of the page
+Quote Post
Pyton_000
post 21.10.2014, 13:43:50
Post #3





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


j.w. Pokażkawałek $columns i $array
Go to the top of the page
+Quote Post
rad11
post 22.10.2014, 10:18:35
Post #4





Grupa: Zarejestrowani
Postów: 1 270
Pomógł: 184
Dołączył: 7.10.2012
Skąd: Warszawa

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


Tablica columns sluzy do pobrania nazw kolumn z konkretnej tabeli, natomiast tablica array sluzy do pobierania wartosci z tej samej tabeli.

tablica $columns

  1. array(11) { [0]=> object(stdClass)#240 (6) { ["Field"]=> string(2) "id" ["Type"]=> string(7) "int(11)" ["Null"]=> string(2) "NO" ["Key"]=> string(3) "PRI" ["Default"]=> NULL ["Extra"]=> string(14) "auto_increment" } [1]=> object(stdClass)#1115 (6) { ["Field"]=> string(4) "city" ["Type"]=> string(12) "varchar(255)" ["Null"]=> string(2) "NO" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [2]=> object(stdClass)#1114 (6) { ["Field"]=> string(6) "powiat" ["Type"]=> string(12) "varchar(255)" ["Null"]=> string(2) "NO" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [3]=> object(stdClass)#1113 (6) { ["Field"]=> string(3) "lat" ["Type"]=> string(13) "decimal(10,7)" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [4]=> object(stdClass)#1112 (6) { ["Field"]=> string(3) "lng" ["Type"]=> string(13) "decimal(10,7)" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [5]=> object(stdClass)#1111 (6) { ["Field"]=> string(5) "count" ["Type"]=> string(7) "int(11)" ["Null"]=> string(2) "NO" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [6]=> object(stdClass)#1110 (6) { ["Field"]=> string(5) "email" ["Type"]=> string(12) "varchar(255)" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [7]=> object(stdClass)#1109 (6) { ["Field"]=> string(3) "key" ["Type"]=> string(4) "text" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [8]=> object(stdClass)#1108 (6) { ["Field"]=> string(6) "accept" ["Type"]=> string(10) "tinyint(4)" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [9]=> object(stdClass)#1107 (6) { ["Field"]=> string(10) "created_at" ["Type"]=> string(8) "datetime" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } [10]=> object(stdClass)#1106 (6) { ["Field"]=> string(10) "updated_at" ["Type"]=> string(8) "datetime" ["Null"]=> string(3) "YES" ["Key"]=> string(0) "" ["Default"]=> NULL ["Extra"]=> string(0) "" } }



tablica $array

  1. object(Illuminate\Database\Eloquent\Collection)#1116 (1) { ["items":protected]=> array(874) { [0]=> object(City)#241 (19) { ["table"]=> string(6) "cities" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(11) { ["id"]=> int(24) ["city"]=> string(8) "BIERUŃ " ["powiat"]=> string(22) "BIERUŃSKO-LĘDZIŃSKI" ["lat"]=> string(10) "50.0899900" ["lng"]=> string(10) "19.0929100" ["count"]=> int(7) ["email"]=> string(33) "radoslaw.wojtkiewicz@egplusww.com" ["key"]=> string(32) "6da8ec98fb5f2d58a40bd71cf962ed0d" ["accept"]=> int(1) ["created_at"]=> NULL ["updated_at"]=> string(19) "2014-10-22 07:37:04" } ["original":protected]=> array(11) { ["id"]=> int(24) ["city"]=> string(8) "BIERUŃ " ["powiat"]=> string(22) "BIERUŃSKO-LĘDZIŃSKI" ["lat"]=> string(10) "50.0899900" ["lng"]=> string(10) "19.0929100" ["count"]=> int(7) ["email"]=> string(33) "radoslaw.wojtkiewicz@egplusww.com" ["key"]=> string(32) "6da8ec98fb5f2d58a40bd71cf962ed0d" ["accept"]=> int(1) ["created_at"]=> NULL ["updated_at"]=> string(19) "2014-10-22 07:37:04" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["with":protected]=> array(0) { } ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [1]=> object(City)#242 (19) { ["table"]=> string(6) "cities" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(11) { ["id"]=> int(25) ["city"]=> string(12) "OSTROŁĘKA " ["powiat"]=> string(11) "OSTROŁĘKA" ["lat"]=> string(10) "53.0876544" ["lng"]=> string(10) "21.5592554" ["count"]=> int(6) ["email"]=> NULL ["key"]=> NULL ["accept"]=> NULL ["created_at"]=> NULL ["updated_at"]=> NULL } ["original":protected]=> array(11) { ["id"]=> int(25) ["city"]=> string(12) "OSTROŁĘKA " ["powiat"]=> string(11) "OSTROŁĘKA" ["lat"]=> string(10) "53.0876544" ["lng"]=> string(10) "21.5592554" ["count"]=> int(6) ["email"]=> NULL ["key"]=> NULL ["accept"]=> NULL ["created_at"]=> NULL ["updated_at"]=> NULL } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["with":protected]=> array(0) { } ["exists"]=> bool(true) ["softDelete":protected]=> bool(false) } [2]=> object(City)#1117 (19) { ["table"]=> string(6) "cities" ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(11) { ["id"]=> int(26) ["city"]=> string(20) "KONSTANCIN-JEZIORNA " ["powiat"]=> string(13) "PIASECZYŃSKI" ["lat"]=> string(10) "52.0938717" ["lng"]=> string(10) "21.1177220" ["count"]=> int(1) ["email"]=> NULL ["key"]=> NULL ["accept"]=> NULL ["created_at"]=> NULL ["updated_at"]=> NULL }


itd.
Go to the top of the page
+Quote Post
Pyton_000
post 22.10.2014, 11:01:43
Post #5





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Mogłeś zrobić z tego hash byłoby łatwiej przeczytać.
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 07:16