Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Pobranie dwóch tabel
tenloginjestzaje...
post
Post #1





Grupa: Zarejestrowani
Postów: 358
Pomógł: 1
Dołączył: 20.07.2014

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


Witam mam problem, nie wiem jak pobrać dwie tabele, do pobrania jednej używam:
  1. $query1 = mysql_query("SELECT DISTINCT `tag` FROM `comments`");
  2. while($row = mysql_fetch_assoc($query1)){echo '';}


Potrzebuje jeszcze pobrać:

  1. $query1 = mysql_query("SELECT DISTINCT `tag` FROM `tags`");
  2. while($row = mysql_fetch_assoc($query1)){echo '';}


Tak żeby w jednym echo były wniki z dwóch tabel. Dziękuje
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tenloginjestzaje...
post
Post #2





Grupa: Zarejestrowani
Postów: 358
Pomógł: 1
Dołączył: 20.07.2014

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


  1. <?php
  2.  
  3. define('_DB_NAME_', 'xxx');
  4.  
  5. define('_DB_SERVER_', 'xxx');
  6.  
  7. define('_DB_USER_', 'xxx');
  8.  
  9. define('_DB_PASSWD_', 'xxx');
  10.  
  11.  
  12. class MySQL{
  13.  
  14. var $m;
  15.  
  16. var $result;
  17.  
  18. public $errors = array();
  19.  
  20. public function __construct(){
  21.  
  22. $this->m = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
  23.  
  24. $this->query('SET charset utf8');
  25.  
  26. $this->errors = array(mysql_errno($this->m), mysql_error($this->m));
  27.  
  28. }
  29.  
  30. public function query($sql){
  31.  
  32. $this->result = mysql_db_query(_DB_NAME_, $sql, $this->m);
  33.  
  34. $this->errors = array(mysql_errno($this->m), mysql_error($this->m));
  35.  
  36. }
  37.  
  38. public function num_rows(){
  39.  
  40. return mysql_num_rows($this->result);
  41.  
  42. }
  43.  
  44. public function affected_rows(){
  45.  
  46. return mysql_affected_rows($this->m);
  47.  
  48. }
  49.  
  50. public function sh_result(){
  51.  
  52. return $this->result;
  53.  
  54. }
  55.  
  56. public function id(){
  57.  
  58. return mysql_insert_id($this->m);
  59.  
  60. }
  61.  
  62. public function escape($string){
  63.  
  64. return mysql_real_escape_string(trim($string), $this->m);
  65.  
  66. }
  67.  
  68. public function fetch_array(){
  69.  
  70. return mysql_fetch_array($this->result, MYSQL_ASSOC);
  71.  
  72. }
  73.  
  74. public function result(){
  75.  
  76. return mysql_result($this->result, 0);
  77.  
  78. }
  79.  
  80. public function __destruct(){
  81.  
  82. $this->errors = array(mysql_errno($this->m), mysql_error($this->m));
  83.  
  84. //mysql_close($this->m);
  85.  
  86. }
  87.  
  88. }
  89.  
  90.  
  91. ?>


Drugi config rózni się jedynie danymi do sql. Nie bardzo wiem jak to ogarnąć.

Ten post edytował tenloginjestzajety 4.07.2015, 21:38:08
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: 9.10.2025 - 11:10