Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php][mysql]wyświetlenie nazw kolumn mysql
newbbbie
post
Post #1





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 4.03.2009

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


Witam... szukam jakiejś funkcji która mi wyświetli nazwy kolumn w danej tabeli...
znalazłem to:
http://forum.php.pl/index.php?showtopic=59...rt=#entry319512

nie pmogło...


znalazłem to:
http://www.codeignitor.com/user_guide/database/fields.html

ale wyskakuje error:

Fatal error: Call to undefined method mysqli_result::list_fields() in C:\Program Files\VertrigoServ\www\tomi\class.mysql.php on line 49


czyli albo nie ma listfields() albo cos zle robie.... pomóżcie (IMG:style_emoticons/default/smile.gif) zależy mi na obiektowym rozwiązaniu tego problemu (IMG:style_emoticons/default/tongue.gif)
Go to the top of the page
+Quote Post
erix
post
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Eeee, a korzystasz z CodeIgnitera? (IMG:style_emoticons/default/tongue.gif)

Wykonaj sobie zapytanie
  1. DESC tabela

i powyciągaj z niego wiersze.
Go to the top of the page
+Quote Post
newbbbie
post
Post #3





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 4.03.2009

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


hm... to nic nie da...

zalozmy ze tabela wyglada tak


|imie---nazwisko|
_____________
|adam--jakistam|
|stefan-----stirliz|

chodzi o wyciagniecie nazw (czyli imie, nazwisko).... o wyciagniecie fieldsow ;]
Go to the top of the page
+Quote Post
Pilsener
post
Post #4





Grupa: Zarejestrowani
Postów: 1 590
Pomógł: 185
Dołączył: 19.04.2006
Skąd: Gdańsk

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


http://pl.php.net/manual/pl/function.mysql-field-name.php - a jak tą funkcje zaimplementujesz to już Twoja sprawa (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
newbbbie
post
Post #5





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 4.03.2009

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


o tym to już wiem... jak napisałem, zależy mi na obiektowym rozwiązaniu problemu (IMG:style_emoticons/default/smile.gif) jest jakis 'zamiennik'?
Go to the top of the page
+Quote Post
celbarowicz
post
Post #6





Grupa: Zarejestrowani
Postów: 253
Pomógł: 31
Dołączył: 30.03.2009
Skąd: Szczecin

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


  1. <?php
  2. $global_dbh=mysql_connect('localhost','root','');
  3. mysql_select_db('selduze3',$global_dbh);
  4.  
  5. function display_db_query($query_string, $connection, $header_bool, $table_params)
  6. {$result_id=mysql_query($query_string, $connection);
  7.  
  8. $column_count=mysql_num_fields($result_id);
  9.  
  10. print("<table $table_params>\n");
  11.  
  12.  
  13.  
  14. if ($header_bool)
  15. {
  16. print("<tr>");
  17.  
  18. for($column_num=0; $column_num<$column_count; $column_num++)
  19. {$field_name=mysql_field_name($result_id,$column_num); //tutaj jest funkcja której szukasz podłącz swoją bazę itabelę
  20. print("<th>$field_name</th>"); //na podstawie książki php4
  21. }
  22.  
  23. print("</tr>\n");
  24. } }
  25.  
  26. //******************************************************
  27. function display_db_table($tablename, $connection, $header_bool, $table_params)
  28. {
  29. $query_string="select * from $tablename";
  30. display_db_query($query_string, $connection, $header_bool, $table_params);
  31. }
  32. ?>
  33.  
  34. <html><head><title> celbarowicz</title></head>
  35. <body>
  36.  
  37. <?php display_db_table("tabela_3",$global_dbh, true,"border=2"); ?>
  38.  
  39.  
  40. </body></html>
  41.  
  42.  
  43.  
  44.  
resztę dopisz sam

Go to the top of the page
+Quote Post

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: 15.09.2025 - 16:26