Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V  < 1 2  
Reply to this topicStart new topic
> [PHP]GROUP_CONCAT a warunek dla rekordu
nospor
post 21.02.2020, 15:02:23
Post #21





Grupa: Moderatorzy
Postów: 36 429
Pomógł: 6289
Dołączył: 27.12.2004




No nie. Kod po edycji ma warunek i wyswietlanie dla kazdej daty oddzielnie


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
inomi13
post 21.02.2020, 15:10:51
Post #22





Grupa: Zarejestrowani
Postów: 95
Pomógł: 0
Dołączył: 16.08.2017

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


Poniżej przesyłam kod

  1. <?php
  2.  
  3. if (!isset($_SESSION['logged']))
  4. {
  5. header('Location: index.php');
  6. exit();
  7. }
  8. else
  9. {
  10. if ($_SESSION['user']=='admin')
  11. {
  12. require_once "connect.php";
  13. $connect = @new mysqli($host, $db_user, $db_password, $db_name);
  14. $result = $connect->query("Select p.name,
  15.  
  16. (Select GROUP_CONCAT(e.adres_email order by d.domain_end SEPARATOR '<hr>') from email e where e.id_person=p.id) as adres_email,
  17.  
  18. GROUP_CONCAT(d.domain_price+d.staff+d.serwer+d.positioning+d.media order by d.domain_end SEPARATOR ' zł <hr>') as domain_prices,
  19.  
  20. GROUP_CONCAT(d.domain_end order by d.domain_end SEPARATOR '<br>') as domain_ends, group_concat(d.domain_name order by d.domain_end SEPARATOR '<hr>') as domain_names
  21.  
  22. from persons p left join domains d on p.id=d.id_person WHERE p.id != 1 group by p.id");
  23. }
  24. else
  25. {
  26.  
  27. header('Location: panel.php');
  28. }}
  29. ?>
  30. <!DOCTYPE HTML>
  31. <html lang="pl">
  32. <head>
  33.  
  34. </head>
  35. <body id="admin">
  36. <div class="header">
  37.  
  38. </div>
  39. <div class="content">
  40. <section class="jumpers">
  41. <div class="row">
  42. <table>
  43. <thead>
  44.  
  45. </thead>
  46. <tbody>
  47. <?php
  48. if($result->num_rows > 0)
  49. {
  50. while($row = $result->fetch_assoc())
  51. {
  52. ?>
  53. <tr class="admin">
  54. <?php
  55.  
  56.  
  57. $oneYearOn3 = date('Y-m-d');
  58.  
  59. $oneYearOn= date('Y-m-d', strtotime($row["domain_ends"]));
  60.  
  61. $pieces3= explode(',',$row["domain_ends"]);
  62.  
  63. $oneYearOn3 = date('Y-m-d');
  64. foreach ($pieces3 as $end) {
  65. if (($end<$oneYearOn3))
  66. {
  67. echo '<td class="box_small_red" data-column="Ważność domeny"><div class="box_admin">'.$end.'</div></td>';
  68. }
  69. else
  70. {
  71. echo '<td class="box_small_green" data-column="Ważność domeny"><div class="box_admin"><font color=red>'.$end.'</font></div></td>';
  72. }
  73. }
  74.  
  75. ?>
  76. </tr>
  77. <?php
  78. }}
  79. ?>
  80. </tbody></table></div>
  81. </div></section></div>
  82. </body>
  83. </html>
  84.  

Go to the top of the page
+Quote Post
nospor
post 21.02.2020, 15:15:41
Post #23





Grupa: Moderatorzy
Postów: 36 429
Pomógł: 6289
Dołączył: 27.12.2004




Masakra jakas....

laczysz DATY przy pomocy <BR> a potem radosnie oddzielasz po PRZECINKU... Nawet nie raczyles spojrzec co ci explode zwraca :/ No szanuj troche czas innych


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
inomi13
post 21.02.2020, 15:17:14
Post #24





Grupa: Zarejestrowani
Postów: 95
Pomógł: 0
Dołączył: 16.08.2017

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


faktycznie przeoczyłem zapytanie sql, poprawiłem zapytanie i teraz wszystko działa smile.gif
Go to the top of the page
+Quote Post
nospor
post 21.02.2020, 15:19:34
Post #25





Grupa: Moderatorzy
Postów: 36 429
Pomógł: 6289
Dołączył: 27.12.2004




Cytat
faktycznie przeoczyłem zapytanie sql

To co przeoczyles to DEBUGOWANIE. Zawsze sprawdzaj na jakich danych operujesz oraz co ci zwracaja.
glupie print_r czy var_dump cie nie zabije a zaoszczedzi mase czasu tobie i innym nieszczesnikom co probuja ci pomoc


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

2 Stron V  < 1 2
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: 19.03.2024 - 04:12