Przykład użycia funkcji GROUP_CONCAT

1
SELECT GROUP_CONCAT(kto ORDER BY kto ASC SEPARATOR ', ') FROM raport_ludzie_spotkania

Złączenie rekordów wątku do jednego stringa, wycinanie 80 znaków stringa:

1
2
3
4
5
6
7
8
9
SELECT t.ticket_id, t.created,
SUBSTRING(last_notes_title, 1, (80 + LOCATE(' ', last_notes_title, 80))) AS last_notes_title,
SUBSTRING(last_notes_body, 1, (80 + LOCATE(' ', last_notes_body, 80))) AS last_notes_body
FROM (
SELECT ticket_id, created,
GROUP_CONCAT(title ORDER BY created DESC SEPARATOR '|') AS last_notes_title,
GROUP_CONCAT(body ORDER BY created DESC SEPARATOR '|') AS last_notes_body
FROM ost_ticket_thread WHERE ticket_id IN (1,2,3,4,5) GROUP BY ticket_id
) AS t

Dodanie linku nad animacją flash

Animację flash należy umieścić w divie. Dodatkowo należy utworzyć div o pozycji absolutnej i rozmiarze animacji flash. W zdarzeniu onclick dla diva obsłużyć otwieranie linku w nowym oknie przeglądarki.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<div id="flashContent" style="position:relative">
  <div>
  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="619" height="116" id="dziendziecka" align="middle">
       <param name="movie" value="/pliki/dziendziecka.swf" />
       <param name="quality" value="high" />
       <param name="bgcolor" value="#ffffff" />
       <param name="play" value="true" />
       <param name="loop" value="true" />
       <param name="wmode" value="window" />
       <param name="scale" value="showall" />
       <param name="menu" value="true" />
       <param name="devicefont" value="false" />
       <param name="salign" value="" />
       <param name="allowScriptAccess" value="sameDomain" />
       <!--[if !IE]>-->
       <object type="application/x-shockwave-flash" data="/pliki/dziendziecka.swf"
width="619" height="116">
            <param name="movie" value="/pliki/dziendziecka.swf" />
            ....
            <param name="allowScriptAccess" value="sameDomain" />
       <!--<![endif]-->
            <a href="http://www.adobe.com/go/getflash">
              <img src="http://www.adobe.com/images/shared/download_buttons/
get_flash_player.gif"

alt="Pobierz odtwarzacz Adobe Flash Player" />
            </a>
       <!--[if !IE]>-->
       </object>
       <!--<![endif]-->
  </object>
  </div>
  <div style="position:absolute;background:transparent;width:619px;height:116px;
left:0;top:0;cursor:pointer" onclick="window.open('/pliki/dziendziecka.pdf','_blank')">

  </div>
</div>

Formatowanie daty w mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SELECT e.name,
DATE_FORMAT(FROM_UNIXTIME(start_time), '%Y-%d-%m') AS start_date_format,
DATE_FORMAT(FROM_UNIXTIME(start_time), '%H:%i:%S') AS start_time_format,
DATE_FORMAT(FROM_UNIXTIME(end_time), '%H:%i:%S') AS end_time_format,
TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(start_time),  FROM_UNIXTIME(end_time))
AS diff_time_minutes_format,
e.room_name,
e.start_time,
e.end_time,
WHERE e.room_id = r.id
 AND DATE_FORMAT(FROM_UNIXTIME(e.start_time), '%Y-%m-%d') <= '2016-05-23'
 AND DATE_FORMAT(FROM_UNIXTIME(e.end_time), '%Y-%m-%d') >= '2016-05-19'
 AND e.name IN ('misiek')
ORDER BY
 e.start_time

Obsługa zadań w systemie Windows

1
2
3
4
5
6
7
8
9
10
SCHTASKS /Create /SC MINUTE /MO 30 /TN rachunek /TR calc.exe
/ST 09:00 /ET 16:00 /SD 19/04/2016 /ED 06/06/2016

SCHTASKS /Query /TN rachunek

SCHTASKS /Run /TN rachunek

SCHTASKS /End  /TN rachunek

SCHTASKS /Delete  /TN rachunek

Wyśrodkowanie tabeli z danymi do rozmiaru okna

1
2
3
4
5
6
7
8
9
10
11
12
13
$(window).resize(function() {
var winW = $(window).width();
var conW = parseInt($('#container').css('width'));
var tabW = parseInt($('table.list').css('width'));

if(winW&gt;conW) {
var margin_left = -((tabW - conW)/2)-10;
$('table.list').css({'margin-left':margin_left});
} else {
$('table.list').css({'margin-left':0});
}
});
$(window).resize();

Tabelka normalna:
tabela

Tabelka wyśrodkowana:
tabela wyśrodkowana