顯示文章

這裡允許您檢視這個會員的所有文章。請注意, 您只能看見您有權限閱讀的文章。


文章 - NARs

頁: [1] 2 3 ... 8
1
網頁技術 / jQuery data table無法呈現?
« 於: 2016-06-24 17:26 »
我想要將curl的資料以jquery datatable呈現 (like this https://datatables.net/examples/api/row_details.html),

response.php :
代碼: [選擇]
echo json_encode($results);

datatables.php:
代碼: [選擇]
    <script>
    function format ( d ) {
    // `d` is the original data object for the row
    return '<table cellpadding="3" cellspacing="0" border="0" style="padding-left:50px;">'+
        '<tr>'+
            '<td>message:</td>'+
            '<td>'+htmlspecialchars(d.message)+'</td>'+
        '</tr>'+
        '<tr>'+
            '<td>id:</td>'+
            '<td>'+d.id+'</td>'+
        '</tr>'+
       
    '</table>';
    }
 
    $(document).ready(function() {
    var table = $('#example').DataTable( {
       
"ajax": {
        'type': 'POST',
        'url': 'response.php',
        "columns": [
            {
                "className":      'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            { "data": "datetime" },
            { "data": "message" },
         
        ],
        "order": [[1, 'asc']]
    } );
     
    // Add event listener for opening and closing details
    $('#example tbody').on('click', 'td.details-control', function () {
        var tr = $(this).closest('tr');
        var row = table.row( tr );
 
        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            // Open this row
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
         }
      } );
     } );
    </script>
html :
代碼: [選擇]
<body>

    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th></th>
                <th>datetime</th>
                <th>message</th>
               
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th></th>
                <th>datetime</th>
                <th>message</th>
               
            </tr>
        </tfoot>
    </table>
  </body>
echo json_encode($results) 是有資料的,但是為什麼會不能呈現出來?

2
各位大大,
要如何將JAva的回傳ArrayList中map 的key和value以表格呈現?


代碼: [選擇]
   ArrayList<Map<String, Object>> arylist = new ArrayList<Map<String, Object>>();
   int index = 0;
   for (SearchHit hit : hits)
   {
        for (Map.Entry entry : map.entrySet())
        {
            map.put(entry.getKey().toString(), entry.getValue());
        }
        arylist.add(index, map);
       index++;
   }
return arylist ;

3
各位大大,
在CSS中,設定了位置,但是在firefox、IE顥示,位置是我想要的排版位置
,但是在chrome中,位置會偏上移,請問要怎麼解決不同瀏覽器的排版呢?

在firefox、IE 中要設定如下 :
代碼: [選擇]
margin-top:-400px; /*map position */
margin-left:-400px; /*map position*/

但是在chrome中卻要改成
代碼: [選擇]
margin-top:-300px; /*map position */
margin-left:-300px; /*map position*/

4
資料庫的格式是varchar(20)
儲存的形式是 2013-12-23 22:43:04
請問要如何取出有相差1分鐘內的紀錄?


例如:
id time
1 2013-12-23 08:20:04
2 2013-12-23 08:20:54
3 2013-12-23 08:20:24
4 2013-12-23 10:43:14
5 2013-12-23 10:43:04
6 2013-12-23 07:43:04
7 2013-12-23 05:43:04
8 2013-12-23 03:43:04


則可以取出

1 2013-12-23 08:20:04
2 2013-12-23 08:20:54
3 2013-12-23 08:20:24


4 2013-12-23 10:43:14
5 2013-12-23 10:43:04

5
網頁技術 / 請問如何讀取mysql畫出圖形?
« 於: 2013-12-11 11:52 »
希望能讀取資料庫資料畫出如附件的圖形,
請問有軟體或套件可以畫出如附件的圖形嗎?

6
原來是有成功的,只是aaa.txt產生在root的目錄裡。
但是我試另一個shell script,但是在17:9時卻沒有執行,
但是如果直接執行是可以執行的
#sh /root/backup.sh


可是在crontab中卻沒有執行,請問各位大大是那裡錯了嗎?

backup.sh
代碼: [選擇]
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

source /root/.bash_profile
sudo /opt/shop/bin/clean_pSB_db.pl \
--mysqldump-opts="--skip-lock-tables" --dbtype=employee --maxdays=3 \
--owmesh-dir=/opt/shop/etc/ \
--dumpdir=/var/log/BACKUP/employee



crontab 的設定:
代碼: [選擇]
9 17 * * *  /bin/sh /root/backup.sh



# pwd backup.sh
/root

# ls -l /root/backup.sh
-rwxr-xr-x 1 root root 287 Aug 17 17:06 /root/backup.sh


7
改成

代碼: [選擇]
#!/bin/sh
test1=$(route)

echo "$test1" > aaa.txt

echo "#`date`" >> aaa.txt

直接去執行 /home/pinky/test.sh,是可以執行的
但是在crontab中卻沒有執行(沒有產生aaa.txt)

8
有~~~
-rwxr-xr-x 1 root root 120 Aug  8 14:53 /home/pinky/test.sh

9
路徑是正確的,查了 /var/log/cron

代碼: [選擇]
Aug  8 14:20:01 pinky_pc crond[24425]: (root) CMD (/home/pinky/test.sh)
Aug  8 14:20:03 pinky_pc crontab[24254]: (root) END EDIT (root)
Aug  8 14:21:01 pinky_pc crond[24461]: (root) CMD (/home/pinky/test.sh)
Aug  8 14:22:01 pinky_pc crond[24514]: (root) CMD (/home/pinky/test.sh)
Aug  8 14:22:24 pinky_pc crond[24532]: (CRON) STARTUP (V5.0)
Aug  8 14:23:01 pinky_pc crond[24542]: (root) CMD (/home/pinky/test.sh)
Aug  8 14:24:01 pinky_pc crond[24553]: (root) CMD (/home/pinky/test.sh)
這是有執行嗎?

10
Linux 討論版 / 如何在crontab 執行shell script ?
« 於: 2012-08-08 14:14 »
各位大大,
我想要在crontab中排程定時執行一支shell script

test.sh :
代碼: [選擇]
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

test1=$(route)

echo "$test1" > aaa.txt

echo "#`date`" >> aaa.txt

我以root的身份執行crontab -e ,加入下面這行在下午一點38分時執行

38  13  *  * *  /home/pinky/test.sh

可是如果有執行的話,應該會新增資料在aaa.txt,可是卻沒有執行這支test.sh,請問是那裡錯了嗎??

11
Nnasen大大,
參考你給的網址在contab -e 加了
代碼: [選擇]
15 16 * * * root killall java每天下午16:15分執行killall java,可是還是沒有執行,請問是我有那裡錯了嗎?

12
請問如果是直接killall java的話,那在crontab上要怎麼設定每天凌晨2點執行killall java?

13
各位大大,
請問要如何用crontab的方式去定期(每天凌晨3點)去終止正在執行的java class(test.class) ??

14
各位大大,
我目前呈現的比例是,
代碼: [選擇]
map.setCenter(new GLatLng(locate[0],locate[1]), 16);請問在google map上要怎麼設定比例,因為所有的marker都在台灣,所以要如何讓map主要只呈現台灣地圖,就可以一次看到所有的marker ?

15
database 討論版 / SQL 語法查詢?
« 於: 2012-06-11 12:27 »
我有一個shoplog table,
表格中的欄位有:
buyer (varchar),buyer_region(varchar),shop(varchar),shop_region(varchar),shoppingtime(datetime),
假設資料內容如下:
+---------------+---------+----------------+---------+---------------------+
| buyer | buyer_region| shop | shop_region| shoppingtime |
+---------------+---------+----------------+---------+---------------------+
| alan | taipei | a_shop | kao | 2012-06-11 00:12:13 |
| john | tainan | b_shop | tainan | 2012-06-12 00:13:15 |
| mary | taichung | c_shop | taipei | 2012-06-11 00:20:40 |
| vivi | kao | d_shop | kao | 2012-06-14 00:21:11 |
| tom | taipei | a_shop | taichung | 2012-06-11 00:22:15 |
| alan | taipei | a_shop | kao | 2012-06-11 00:12:13 |
| alan | taipei | a_shop | kao | 2012-06-12 05:31:23 |
| tom | taipei | a_shop | hsinchu | 2012-06-11 00:22:15 |
| alan | hsinchu | a_shop | kao | 2012-06-19 00:31:23 |

請問要怎麼取出本週內,在同一個buyer_region的buyer向同一個shop_region的shop的次數,也就是buyer,buyer_region| shop,shop_region這四個值要一樣,歸類為同一群,並且也可以顯示各群購買的時間區間??

以上面的例子的話,如果是取出6/11~6/17內在同一個buyer_region的buyer向同一個shop_region的shop的次數,
結果應該是

+---------------+---------+----------------+---------+----------------+---------------------+
| buyer | buyer_region| shop | shop_region| counts | firsttime | endtime
+---------------+---------+----------------+---------+----------------+---------------------+
| alan | taipei | a_shop | kao |3 |2012-06-11 00:12:13 |2012-06-12 05:31:23
| john | tainan | b_shop | tainan | 1 |2012-06-12 00:13:15 |2012-06-12 00:13:15
| mary | taichung | c_shop | taipei | 1 |2012-06-11 00:20:40 |2012-06-11 00:20:40
| vivi | kao | d_shop | kao | 1 |2012-06-14 00:21:11 |2012-06-14 00:21:11
| tom | taipei | a_shop | taichung | 1 |2012-06-11 00:22:15 |2012-06-11 00:22:15
| tom | taipei | a_shop | hsinchu | 1 |2012-06-11 00:22:15 |2012-06-11 00:22:15

請問這要怎麼做呢??

16
各位大大,
請問如果要5分鐘執行一次,和一小時執行一次 , 執行的都是同一個任務,
請問要麼做?

17
網頁技術 / Re: 如何使用保留原本form的值?
« 於: 2012-05-11 11:44 »
Yamaka 大大,
我加了onclick去呼叫javascript 把值寫回去,可是還是不行,請問是我漏掉什麼了嗎?



代碼: [選擇]
<input type="submit" name="submit_form" value="查詢" onclick="getvalue()" />

代碼: [選擇]
<script language="javascript">
 function getvalue()
 {
 
  document.getElementById("f_rangeStart").value=<? echo $_POST['f_rangeStart'] ; ?>;
document.getElementById("f_rangeEnd").value= <? echo $_POST['f_rangeEnd'] ;?>;


 }
 </script>

18
網頁技術 / 如何使用保留原本form的值?
« 於: 2012-05-09 16:07 »
各位大大,
要如何在用form的POST傳值到同一頁的PHP後,form裡面原本輸入的表格資料不會消失。
因為我在用form傳送使用者輸入的表格資料查詢到同一頁的PHP時,form裡面原本填入的表格內容會不見,
請問各位大大這要怎麼改呢?

代碼: [選擇]
    <form method="post"  action="<?php echo $_SERVER[&#39;PHP_SELF&#39;]; ?>">   
<table width="500" border="1">
             <tr>
                 <td colspan="3"  >查詢條件</td>
            </tr>
  <tr>
              <td>查詢日期</td>
    <td>
                 <input id="f_rangeStart" name="f_rangeStart"/>
                 <button id="f_rangeStart_trigger" type="button">...</button>
                  <script type="text/javascript">
                  RANGE_CAL_1 = new Calendar({
                          inputField: "f_rangeStart",
                          dateFormat: "%Y-%m-%d",
                          trigger: "f_rangeStart_trigger",
                          bottomBar: false,
                          onSelect: function() {
                                  this.hide();
                          }
                  });
               
                </script>
                </td>
    <td>
                <input id="f_rangeEnd"  name="f_rangeEnd"/>
                <button id="f_rangeEnd_trigger" type="button">...</button>
               
           <script type="text/javascript">
                  RANGE_CAL_2 = new Calendar({
                          inputField: "f_rangeEnd",
                          dateFormat: "%Y-%m-%d",
                          trigger: "f_rangeEnd_trigger",
                          bottomBar: false,
                          onSelect: function() {
                                  this.hide();
                          }
                  });
               
                </script></td>
 
      </tr>
             
  <tr>
             
    <td colspan="3">  <input type="submit" name="submit_form" value="查詢" /></td>
   
      </tr>
  </table>
       
</form>


19
網頁技術 / open flash chart 使用 ?
« 於: 2012-05-08 16:51 »
各位大大,
我用open flash chart去呈現每一個規則所佔的比例的pie chart,可是在網頁上呈現時卻一片空白,
有大大使用過這個套件嗎?請問是那裡錯了嗎?

chart.html
代碼: [選擇]
    <html>
    <head>
        <title></title>
    <script type="text/javascript" src="js/swfobject.js"></script>
    <script type="text/javascript">

    swfobject.embedSWF(
      "open-flash-chart.swf?t=" + (new Date()).getTime()", "pie_chart",
      "700", "400", "9.0.0", "expressInstall.swf",
      {"data-file":" data.php "} );
    </script>
    </head>
    <body>
    <div id="pie_chart">
    </div>
    </body>
    </html>


data.php
代碼: [選擇]
    <?php
    $die 
false;
    
$link = @mysql_connect(&#39;localhost&#39;,&#39;user&#39;, &#39;pwd&#39;) or ($die = true);
    
if($die)
    {
        echo &
#39;<h3>Database connection error!!!</h3>&#39;;
        
echo &#39;A connection to the Database could not be established.<br />&#39;;
        
echo &#39;Please check your username, password, database name and host.<br />&#39;;
        
echo &#39;Also make sure <i>mysql.class.php</i> is rightly configured!<br /><br />&#39;;
    
}
    
mysql_select_db(&#39;testdatabase&#39;);
    
include_once &#39;php-ofc-library/open-flash-chart.php&#39;;
    
$query mysql_query(&#39;select count(*) counts,rule from  book where modifydate between &#39;2012-05-06&#39; and &#39;2012-05-12&#39; and cat = &#39;computer&#39; group by rule ;
    
&#39;);
    
While($queryRow mysql_fetch_array($queryMYSQL_ASSOC))
    {
        
$label[] = $queryRow[&#39;rule &#39;];
        
$dataForGraph[] = intval($queryRow[&#39;counts&#39;]);
    
}
    
$title = new title( &#39;The grades distribution : &#39;.date("D M d Y").&#39; are&#39; );
    
$title->set_style( &#39;{color: #567300; font-size: 14px}&#39; );
    
$chart = new open_flash_chart();
    
$chart->set_title$title );

    
$pie = new pie();
    
$pie->set_alpha(0.6);
    
$pie->set_start_angle35 );
    
$pie->add_animation( new pie_fade() );
    
$pie->set_tooltip( &#39;#val# of #total#<br>#percent# of total strength&#39; );
    
$pie->set_colours( array(&#39;#1C9E05&#39;,&#39;#FF368D&#39;,&#39;#1A3453&#39;,&#39;#1A3789&#39;) );
    
$pie->set_values( array(new pie_value($dataForGraph[0], "rule" $label[0]),
                    new 
pie_value($dataForGraph[1], "rule " $label[1]),
                    new 
pie_value($dataForGraph[2], "rule " $label[2]),
                new 
pie_value($dataForGraph[3], "rule " $label[3])) );

    
$chart->add_element$pie );
    echo 
$chart->toPrettyString();
    
?>



20
請問各位大大,
我的頁面在PC和NB上的顯示會有版面不一樣的問題,例如,top.php(呈現logo)在PC上和NB上的顯示不一樣,在PC上是很正常,可是在NB上會沒有完整呈現logo,如果去調整比例,又會變成PC上看起來比例不對,請問這要怎麼解決?

代碼: [選擇]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>home</title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>


 <frameset rows="10%,*" cols="*" frameborder="0" >
    <frame src="top.php" name="top" scrolling="no" />
    <frameset rows="*" cols="210px,*">
      <frame src="left.php" name="left" noresize scrolling="no" />
      <frame src="content.php" name="center" noresize scrolling="no"/>
    </frameset>
    <noframes></noframes>
   

<body>
</body>
</html>

21
database 討論版 / 批次存入TABLE ?
« 於: 2012-03-16 13:51 »
請問各位大大,

要如何將A_table 的紀錄是不是中有超過100筆的話,要如何將"ID最小的超過的筆數"(也就是將比較舊的資料所超過的筆數)移到B_TABLE
中,並且將移到B_TABLE的紀錄從原本A_TABLE中刪除??

22
database 討論版 / Re: SQL 條件查詢?
« 於: 2012-03-16 11:47 »
各位大大,
原本以為可以用OR來解決,但是好像查詢結果還是有錯誤的

stime 是 2012-03-12 而且 etime 是null 以及 etime 是 2012-03-12的紀錄?
ID      ip                           create                                           update
1      192.168.1.5            2012-03-10 15:48:05                2012-03-12 10:48:05
2      192.168.1.2              2012-03-11 07:48:05               null
3      192.168.1.3             2012-03-12 08:48:05                null
4      192.168.1.1             2012-03-12 09:48:05                null
5      192.168.1.6             2012-03-12 15:48:05                2012-03-12 17:48:05
6      192.168.1.7              2012-03-12 18:45:05                2012-03-12 19:48:05

我想查詢條件 是ip = 192.168.1.1 , 而且取出的日期限制是 (1)create是2012-03-12 而且update是null (代表資料是2012-03-12新增的資料)或是
(2) update是2012-03-12 (資料是2012-03-12更新的資料)
也就是我想取出192.168.1.1 是2012-03-12新增或是更新的資料


以上面的例子的話,取出的紀錄應該是 1筆
4      192.168.1.1             2012-03-12 09:48:05                null


所以我下的SQL查詢是:

 select * from A_TABLE  where ip = '192.168.1.1' and create like '2012-03-12 %' and update is null or update like '2012-03-12 %' ;

但是卻取出4筆
1      192.168.1.5            2012-03-10 15:48:05                2012-03-12 10:48:05
4      192.168.1.1             2012-03-12 09:48:05                null
5      192.168.1.6             2012-03-12 15:48:05                2012-03-12 17:48:05
6      192.168.1.7              2012-03-12 18:45:05                2012-03-12 19:48:05

23
database 討論版 / Re: SQL 條件查詢?
« 於: 2012-03-13 13:22 »
原來可以用or 來解決,已經解決了,感謝大大的回覆

24
database 討論版 / SQL 條件查詢?
« 於: 2012-03-13 12:32 »
請問各位大大,
要怎麼取出同時有兩個條件的情況下的紀錄?
stime 是 2012-03-12 而且 etime 是null 以及 etime 是 2012-03-12的紀錄?
ID stime etime
1 2012-03-10 15:48:05 2012-03-12 10:48:05
2 2012-03-11 07:48:05 null
3 2012-03-12 08:48:05 null
4 2012-03-12 09:48:05 null
5 2012-03-12 15:48:05 2012-03-12 17:48:05
6 2012-03-12 18:45:05 2012-03-12 19:48:05



以上面的例子的話,取出的紀錄應該是 5筆
1 2012-03-10 15:48:05 2012-03-12 10:48:05 // etime 是 2012-03-12
3 2012-03-12 08:48:05 null //stime 是 2012-03-12 而且 etime 是null
4 2012-03-12 09:48:05 null //stime 是 2012-03-12 而且 etime 是null
5 2012-03-12 15:48:05 2012-03-12 17:48:05 // etime 是 2012-03-12
6 2012-03-12 18:45:05 2012-03-12 19:48:05 // etime 是 2012-03-12

25
各位大大,
有一台遠端主機,可以遠端連到host,想在VM上安裝一套工具,它是以live CD 的安裝方式,請問可以在VM上在無網路的情況下安裝嗎?

26
網頁技術 / Re: google map function ?
« 於: 2011-10-20 16:31 »
但是要傳兩個值,請問要怎麼用selectname.selectedIndex.value傳過去???

27
網頁技術 / Re: google map function ?
« 於: 2011-10-11 15:59 »

Yamaka大大,

option value 就是map的latitude 和longitude
代碼: [選擇]
echo'<option value="'.$latitude.','.$longitude.'">'.$ipv4.'</option>';

28
網頁技術 / Re: google map function ?
« 於: 2011-10-11 11:56 »
Yamaka大大,
我的意思是list box會列出mysql 的資料
當使用者選擇後,按下button時,map會移動到使用者所選擇的點.
移動的function就是movemarker,但是要怎麼把$latitud和$longitude代入function中???

29
網頁技術 / Re: google map function ?
« 於: 2011-10-07 15:03 »
俺是博士大大,
現在list的選項會從mysql代入,


代碼: [選擇]
   <?
   $db->query("select IPv4,Latitude,longitude,Description from Server;");
         $result_num = $db->get_num_rows();
   echo'<select name="List">';
   echo '<option selected>Choose One</option>';
           while($row = $db->fetch_array())
      {

        $latitude = $row['Latitude'];
        $longitude= $row['longitude'];
         $ipv4 = $row['IPv4'];
$desc = $row['Description'];
  $testServer = $ipv4;

echo'<option value="'.$latitude.','.$longitude.'">'.$ipv4.'</option>';
}
echo '<input type="button" onClick="javascript:moveMarker(這裡要怎麼代入所選的$latitud和$longitude ????);" value="GO">';
echo'</select>';
     


 ?>





30
網頁技術 / Re: google map function ?
« 於: 2011-10-07 14:59 »
俺是博士大大,
現在就是卡在要怎麼在moveMarker中代入兩個參數??
大大可以指點一下嗎?

頁: [1] 2 3 ... 8