For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Sunday, May 31, 2015

How to use jquery dataTables

<!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>Untitled Document</title>

<link href="jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
 <script src="jquery.js"></script>
 <script src="jquery.dataTables.min.js"></script>

</head>

<body>

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>

    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>

    <tbody>
        <tr>
            <td>A111111111111</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>B1111111111111</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
        <tr>
            <td>C1111111</td>
            <td>Junior Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$86,000</td>
        </tr>
        <tr>
            <td>D111111111111</td>
            <td>Senior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
            <td>$433,060</td>
        </tr>
        <tr>
            <td>E11111111111</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>33</td>
            <td>2008/11/28</td>
            <td>$162,700</td>
        </tr>
        <tr>
            <td>F111111111111</td>
            <td>Integration Specialist</td>
            <td>New York</td>
            <td>61</td>
            <td>2012/12/02</td>
            <td>$372,000</td>
        </tr>
        <tr>
            <td>G1111111111111</td>
            <td>Sales Assistant</td>
            <td>San Francisco</td>
            <td>59</td>
            <td>2012/08/06</td>
            <td>$137,500</td>
        </tr>
        <tr>
            <td>H11111111111</td>
            <td>Integration Specialist</td>
            <td>Tokyo</td>
            <td>55</td>
            <td>2010/10/14</td>
            <td>$327,900</td>
        </tr>
        <tr>
            <td>I22222222222222222</td>
            <td>Javascript Developer</td>
            <td>San Francisco</td>
            <td>39</td>
            <td>2009/09/15</td>
            <td>$205,500</td>
        </tr>
        <tr>
            <td>J11111111111111</td>
            <td>Software Engineer</td>
            <td>Edinburgh</td>
            <td>23</td>
            <td>2008/12/13</td>
            <td>$103,600</td>
        </tr>
        <tr>
            <td>K1111111111111</td>
            <td>Office Manager</td>
            <td>London</td>
            <td>30</td>
            <td>2008/12/19</td>
            <td>$90,560</td>
        </tr>
        <tr>
            <td>L111111111111</td>
            <td>Support Lead</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2013/03/03</td>
            <td>$342,000</td>
        </tr>
        <tr>
            <td>M1111111111111</td>
            <td>Regional Director</td>
            <td>San Francisco</td>
            <td>36</td>
            <td>2008/10/16</td>
            <td>$470,600</td>
        </tr>
        <tr>
            <td>N11111111111111</td>
            <td>Senior Marketing Designer</td>
            <td>London</td>
            <td>43</td>
            <td>2012/12/18</td>
            <td>$313,500</td>
        </tr>
        <tr>
            <td>O1111111111111</td>
            <td>Regional Director</td>
            <td>London</td>
            <td>19</td>
            <td>2010/03/17</td>
            <td>$385,750</td>
        </tr>
        <tr>
            <td>P11111111111111</td>
            <td>Marketing Designer</td>
            <td>London</td>
            <td>66</td>
            <td>2012/11/27</td>
            <td>$198,500</td>
        </tr>
        <tr>
            <td>Q1111111111111111</td>
            <td>Chief Financial Officer (CFO)</td>
            <td>New York</td>
            <td>64</td>
            <td>2010/06/09</td>
            <td>$725,000</td>
        </tr>
        <tr>
            <td>R111111111111111</td>
            <td>Systems Administrator</td>
            <td>New York</td>
            <td>59</td>
            <td>2009/04/10</td>
            <td>$237,500</td>
        </tr>
        <tr>
            <td>S11111111111111</td>
            <td>Software Engineer</td>
            <td>London</td>
            <td>41</td>
            <td>2012/10/13</td>
            <td>$132,000</td>
        </tr>
        <tr>
            <td>T11111111111111</td>
            <td>Personnel Lead</td>
            <td>Edinburgh</td>
            <td>35</td>
            <td>2012/09/26</td>
            <td>$217,500</td>
        </tr>
        <tr>
            <td>U1111111111111</td>
            <td>Development Lead</td>
            <td>New York</td>
            <td>30</td>
            <td>2011/09/03</td>
            <td>$345,000</td>
        </tr>
        <tr>
            <td>V1111111111111</td>
            <td>Chief Marketing Officer (CMO)</td>
            <td>New York</td>
            <td>40</td>
            <td>2009/06/25</td>
            <td>$675,000</td>
        </tr>
        <tr>
            <td>W1111111111111</td>
            <td>Pre-Sales Support</td>
            <td>New York</td>
            <td>21</td>
            <td>2011/12/12</td>
            <td>$106,450</td>
        </tr>
        <tr>
            <td>X11111111111111</td>
            <td>Sales Assistant</td>
            <td>Sidney</td>
            <td>23</td>
            <td>2010/09/20</td>
            <td>$85,600</td>
        </tr>
        <tr>
            <td>Y111111111111111</td>
            <td>Chief Executive Officer (CEO)</td>
            <td>London</td>
            <td>47</td>
            <td>2009/10/09</td>
            <td>$1,200,000</td>
        </tr>
        <tr>
            <td>Z1111111111111</td>
            <td>Developer</td>
            <td>Edinburgh</td>
            <td>42</td>
            <td>2010/12/22</td>
            <td>$92,575</td>
        </tr>
        <tr>
            <td>A222222222222</td>
            <td>Regional Director</td>
            <td>Singapore</td>
            <td>28</td>
            <td>2010/11/14</td>
            <td>$357,650</td>
        </tr>
        <tr>
            <td>A33333333333333</td>
            <td>Software Engineer</td>
            <td>San Francisco</td>
            <td>28</td>
            <td>2011/06/07</td>
            <td>$206,850</td>
        </tr>
        <tr>
            <td>A44444444444444</td>
            <td>Chief Operating Officer (COO)</td>
            <td>San Francisco</td>
            <td>48</td>
            <td>2010/03/11</td>
            <td>$850,000</td>
        </tr>
        <tr>
            <td>A5555555555555</td>
            <td>Regional Marketing</td>
            <td>Tokyo</td>
            <td>20</td>
            <td>2011/08/14</td>
            <td>$163,000</td>
        </tr>
        <tr>
            <td>A6666666666666666</td>
            <td>Integration Specialist</td>
            <td>Sidney</td>
            <td>37</td>
            <td>2011/06/02</td>
            <td>$95,400</td>
        </tr>
        <tr>
            <td>A777777777777</td>
            <td>Developer</td>
            <td>London</td>
            <td>53</td>
            <td>2009/10/22</td>
            <td>$114,500</td>
        </tr>
        <tr>
            <td>A888888888888888</td>
            <td>Technical Author</td>
            <td>London</td>
            <td>27</td>
            <td>2011/05/07</td>
            <td>$145,000</td>
        </tr>
        <tr>
            <td>A99999999999999999</td>
            <td>Team Leader</td>
            <td>San Francisco</td>
            <td>22</td>
            <td>2008/10/26</td>
            <td>$235,500</td>
        </tr>
        <tr>
            <td>A100000000000000000</td>
            <td>Post-Sales support</td>
            <td>Edinburgh</td>
            <td>46</td>
            <td>2011/03/09</td>
            <td>$324,050</td>
        </tr>
        <tr>
            <td>A121212121212121111</td>
            <td>Marketing Designer</td>
            <td>San Francisco</td>
            <td>47</td>
            <td>2009/12/09</td>
            <td>$85,675</td>
        </tr>
        <tr>
            <td>AAAAAAAAAAAAAAAA</td>
            <td>Office Manager</td>
            <td>San Francisco</td>
            <td>51</td>
            <td>2008/12/16</td>
            <td>$164,500</td>
        </tr>
        <tr>
            <td>BBBBBBBBBBBBBBBB</td>
            <td>Secretary</td>
            <td>San Francisco</td>
            <td>41</td>
            <td>2010/02/12</td>
            <td>$109,850</td>
        </tr>
        <tr>
            <td>CCCCCCCCCCCCCC</td>
            <td>Financial Controller</td>
            <td>San Francisco</td>
            <td>62</td>
            <td>2009/02/14</td>
            <td>$452,500</td>
        </tr>
        <tr>
            <td>DDDDDDDDDDDDDDDD</td>
            <td>Office Manager</td>
            <td>London</td>
            <td>37</td>
            <td>2008/12/11</td>
            <td>$136,200</td>
        </tr>
        <tr>
            <td>EEEEEEEEEEEEEEE</td>
            <td>Director</td>
            <td>New York</td>
            <td>65</td>
            <td>2008/09/26</td>
            <td>$645,750</td>
        </tr>
        <tr>
            <td>FFFFFFFFFFFFFFFFFF</td>
            <td>Support Engineer</td>
            <td>Singapore</td>
            <td>64</td>
            <td>2011/02/03</td>
            <td>$234,500</td>
        </tr>
        <tr>
            <td>GGGGGGGGGGGGGGGGGGG</td>
            <td>Software Engineer</td>
            <td>London</td>
            <td>38</td>
            <td>2011/05/03</td>
            <td>$163,500</td>
        </tr>
        <tr>
            <td>HHHHHHHHHHHHH Yamamoto</td>
            <td>Support Engineer</td>
            <td>Tokyo</td>
            <td>37</td>
            <td>2009/08/19</td>
            <td>$139,575</td>
        </tr>
        <tr>
            <td>IIIIIIIIIIIIII Walton</td>
            <td>Developer</td>
            <td>New York</td>
            <td>61</td>
            <td>2013/08/11</td>
            <td>$98,540</td>
        </tr>
        <tr>
            <td>JJJJJJJJJJJJJJJ Camacho</td>
            <td>Support Engineer</td>
            <td>San Francisco</td>
            <td>47</td>
            <td>2009/07/07</td>
            <td>$87,500</td>
        </tr>
        <tr>
            <td>KKKKKKKKKKKKKKKKK Baldwin</td>
            <td>Data Coordinator</td>
            <td>Singapore</td>
            <td>64</td>
            <td>2012/04/09</td>
            <td>$138,575</td>
        </tr>
        <tr>
            <td>LLLLLLLLLLLLLLL Frank</td>
            <td>Software Engineer</td>
            <td>New York</td>
            <td>63</td>
            <td>2010/01/04</td>
            <td>$125,250</td>
        </tr>
        <tr>
            <td>MMMMMMMMMMMMMMM Serrano</td>
            <td>Software Engineer</td>
            <td>San Francisco</td>
            <td>56</td>
            <td>2012/06/01</td>
            <td>$115,000</td>
        </tr>
        <tr>
            <td>NNNNNNNNNNNNNNNN Acosta</td>
            <td>Junior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>43</td>
            <td>2013/02/01</td>
            <td>$75,650</td>
        </tr>
        <tr>
            <td>OOOOOOOOOOOOO Stevens</td>
            <td>Sales Assistant</td>
            <td>New York</td>
            <td>46</td>
            <td>2011/12/06</td>
            <td>$145,600</td>
        </tr>
        <tr>
            <td>PPPPPPPPPPPPP Butler</td>
            <td>Regional Director</td>
            <td>London</td>
            <td>47</td>
            <td>2011/03/21</td>
            <td>$356,250</td>
        </tr>
        <tr>
            <td>QQQQQQQQQQQQ Greer</td>
            <td>Systems Administrator</td>
            <td>London</td>
            <td>21</td>
            <td>2009/02/27</td>
            <td>$103,500</td>
        </tr>
        <tr>
            <td>RRRRRRRRRRRR Alexander</td>
            <td>Developer</td>
            <td>San Francisco</td>
            <td>30</td>
            <td>2010/07/14</td>
            <td>$86,500</td>
        </tr>
        <tr>
            <td>SSSSSSSSSSSSSSSS Decker</td>
            <td>Regional Director</td>
            <td>Edinburgh</td>
            <td>51</td>
            <td>2008/11/13</td>
            <td>$183,000</td>
        </tr>
        <tr>
            <td>TTTTTTTTTTTTTTTT Bruce</td>
            <td>Javascript Developer</td>
            <td>Singapore</td>
            <td>29</td>
            <td>2011/06/27</td>
            <td>$183,000</td>
        </tr>
        <tr>
            <td>UUUUUUUUUU Snider</td>
            <td>Customer Support</td>
            <td>New York</td>
            <td>27</td>
            <td>2011/01/25</td>
            <td>$112,000</td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
 
$('#example').dataTable({
          "bPaginate": true,
          "bLengthChange": true,
          "bFilter": true,
          "bSort": true,
          "bInfo": true,
          "bAutoWidth": true
        });


} );


</script>
</body>
</html>
Share:

Thursday, May 28, 2015

How to fix any HTML tag at any position

Problem:

How to fix any HTML tag at any position for ex: fix a div at right bottom corner?

Solution:

Use style z-index, bottom, right attribute

Example:

<div id="loading_msg" style="position: fixed; z-index: 99;  bottom: 15px; right: 10px;
    display:; background-color:#CC99FF">Loading now Please wait...</div>
Share:

Tuesday, May 26, 2015

Scrolling paging in PHP

Problem:

Database paging without paging page number.  This is same as Facebook and Tumblr like paging.

Solution:

By using Ajax you can achieve that like scroll paging.

Example:

Use below code. Assuming 1 to 10th records already showing.

index.php
<script type="text/javascript" src="jquery-1.6.js"></script>
<div id="mydiv">
<p>Database paging </p><p>without paging</p><p>page number</p><p>This is same as Facebook</p><p>and Tumblr.</p><p>like paging.</p><p>Assuming 1 to 10th records already showing.</p> <p>Next 11th to end of records will show when scroll page.</p>

<p>1 record</p><p>2 record</p><p>3 record</p><p>4 record</p><p>5 record</p><p>6 record</p><p>7 record</p><p>8 record</p><p>9 record</p><p>10 record</p>   </div>

<a id="loading_img" style="position:fixed; z-index: 99;bottom: 15px; right: 10px; display:none;">Loading... <img src="ajax-loader.gif" /></a>

<script type="text/javascript">
var page = 1;
$(window).scroll(function () {
currentX = $(window).scrollTop();
if  ($(window).scrollTop() == $(document).height() - $(window).height()){
$('a#loading_img').show('fast');
$.get('mydb.php?page=' + page, function(data) {
$('#mydiv').append(data);
$('a#loading_img').hide('fast');
}
);
page++;
}
});
</script>



mydb.php

<?php
$mysqli = new mysqli('localhost', 'root', '','mydb');
$pg=$_GET['page'];
$pg=$pg*10;
$sql='SELECT *FROM book_wise_test ORDER BY book_wise_test_id LIMIT '.$pg .', 10';
$result  = $mysqli->query($sql);
while($row = $result->fetch_assoc()) {
$book_wise_test_id=$row['book_wise_test_id'];
$book_nm=$row['book_nm'];
echo $book_wise_test_id.'======'.$book_nm.'<br/><br/>';
}
?>
Share:

Monday, May 11, 2015

Message: Undefined variable: 0 in CodeIgniter PHP

Problem:

Sometime while working with CodeIngiter / PHP you may encounter "Undefined variable: 0" error.
It surprise to that is "0" (Zero) could be a variable!

Solution:

This "Undefined variable: 0" error come when you use double dollar sign in variable. so remove one dollar ($) sign from variable and error will gone.

Example:

See the below code, specially in red color, it having $$ sign:

$data = array( 'u_login' => $row->u_login,
                        'user_type_id' => $user_type_id,
'user_id'=>$row->user_id,
'transporter_id'=>$transporter_id,
'limit_cr'=>$limit_cr,
'u_c_date'=>$row->u_c_date,
'total_trucks'=>$total_trucks,
'total_liter'=>$total_liter,
'pump_id'=> $$pump_id
                        );

jut remove one $ sign.
Share:

Wednesday, May 06, 2015

How to convert eps file to jpg file

Problem:

How to convert .eps file to .jpg file

Solution:

It is simple, use ImageMagick and below java code. if you expert in PHP or .Net then you can easily convert it same as me.

Example:

import="java.util.*"%>  
import="java.io.*"%>
 
try
    {
        Runtime runTime = Runtime.getRuntime();
        Process process = runTime.exec ("C:/Program Files/ImageMagick-6.5.4-Q16/convert.exe c:/Art1.eps c:/art1.jpg");
        //InputStream inputStream = process.getInputStream();
        //InputStreamReader   inputStreamReader = new InputStreamReader (inputStream);
        //BufferedReader bufferedReader = new BufferedReader(
inputStreamReader);
        ///String line = null;
        //while ( (line = bufferedReader.readLine()) != null )
        //    System.out.println(line);
        int exitVal = process.waitFor();
        System.out.println ("Process exitValue:  " + exitVal );
    }
    catch (Throwable t)
    {
        t.printStackTrace();
    }
Share:

Tuesday, May 05, 2015

How to load JavaScript file async in Magento

Problem:

By async loading JavaScript it will boost up your site, so how to load JavaScript file async in Magento.  In Magento there are two methods to load JavaScript .
1- By addItem
2-By addJs

Solution:

By using async option in <params>async</params> script tag you can load it.

Example:

Open your local.xml file it will be in the "app\design\frontend\default\YOUR-THEME-NAME\layout" folder.

1- By addItem
<action method="addItem">
    <type>skin_js</type>
    <name>js/jquery.mousewheel.min.js</name>
   <params>async</params>
</action>


2-By addJs
<action method="addJs">
     <script>scriptaculous/effects.js</script>
     <params>async</params>
</action>




Share:

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip