Post form with checkbox & checkboxgroup with JavaScript/jQuery

Simple checkbox group(demo):

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Checkbox group form</title>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
</head>

<body>
<?php
if ($_POST):
?>
    <pre>
    <?php print_r($_POST['CheckboxGroup1']); ?>
    </pre>
<?php
endif;// if ($_POST)
?>
<form name="formCheckbox" id="formCheckbox" method="post" action="">
  <p>
    <label>
      <input type="checkbox" name="CheckboxGroup1[]" value="checkbox1" id="CheckboxGroup1_0">
      Checkbox One</label>
    <br>
    <label>
      <input type="checkbox" name="CheckboxGroup1[]" value="checkbox2" id="CheckboxGroup1_1">
      Checkbox Two</label>
    <br>
    <label>
      <input type="checkbox" name="CheckboxGroup1[]" value="checkbox3" id="CheckboxGroup1_2">
      Checkbox Tree</label>
    <br>
    <label>
      <input type="checkbox" name="CheckboxGroup1[]" value="checkbox4" id="CheckboxGroup1_3">
      Checkbox Four</label>
    <br>
    <label>
      <input type="submit" name="submit_button" id="submit_button" value="Submit">
    </label>
    <br>
    <label>
      <input type="button" name="checkedbutton" id="checkedbutton"value="View Checked">
    </label>
    <br>
  </p>
</form>
<script>
$("#checkedbutton").click(function() {
    var areChecked = [];
    var i = 0;

    $.each($( "input:checkbox:checked" ), function(){
        areChecked[i++] = $(this).val();
    });
    alert( "Checked: "+areChecked.join() );
});
</script>
</body>
</html>

Flex spark HSlider

Flash Builder Premium(Flex) 4.5 (build 308971) Adobe Themes – Spark (Default). Tip: right click on an example and choose “View Source”.

Default HSlider:
This movie requires Flash Player 9
HSlider liveDragging:
This movie requires Flash Player 9
HSlider change:
This movie requires Flash Player 9
HSlider dataTipPrecision & stepSize:
This movie requires Flash Player 9

MySQL select from multiple tables

Lets have three tables, only the first one is with unique index: TableA, TableB & TableC

CREATE TABLE IF NOT EXISTS `tableA` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`NAME` varchar(100) NOT NULL,
`SURNAME` varchar(100) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `tableB` (
  `tableA_ID` int(11) NOT NULL,
  `WORK_TITLE` varchar(100) NOT NULL,
  `WORK_PLACE` varchar(100) NOT NULL,
  `WORK_NAME` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tableC` (
  `tableA_ID` int(11) NOT NULL,
  `HOME_TOWN` varchar(100) NOT NULL,
  `HOME_ADDRESS` varchar(255) NOT NULL,
  `HOME_PHONE` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

TableA is populated with people, tableB is populated with their work history and tableC with places they have lived. Something like this:

mysql> SELECT * FROM tableA;
+----+----------+------------+
| ID | NAME     | SURNAME    |
+----+----------+------------+
|  1 | Nicholas | Petman     |
|  2 | Marry    | Luddington |
|  3 | Rise     | Courtenay  |
|  4 | Anna     | Borges     |
|  5 | Thomas   | Hulme      |
+----+----------+------------+
5 rows in set (0.00 sec)

mysql> SELECT * FROM tableB;
+-----------+-----------------------------------+--------------------+-----------------------+
| tableA_ID | WORK_TITLE                        | WORK_PLACE         | WORK_NAME             |
+-----------+-----------------------------------+--------------------+-----------------------+
|         1 | Account Supervisor                | Massachusetts, MA  | New ResearchTecno     |
|         1 | Office Manager                    | Nevada, NV         | Kombaners Networks    |
|         1 | Office Supervisor                 | New York, NY       | Delta Office          |
|         1 | Director Accounts                 | Florida, FL        | Florida Main Company  |
|         1 | Director Distribution             | Delaware, DE       | Cofice Three United   |
|         2 | Director Office Management        | Montana, MT        | Hills Sky Limited     |
|         2 | Distribution Director             | North Carolina, NC | Brassel Foods Network |
|         3 | EEO Manager                       | Michigan, MI       | Clear Water Eng.      |
|         5 | Electrician Maintenance           | South Dakota, SD   | Serdsc Inc.           |
|         5 | Electrician Maintenance           | Tennessee, TN      | Joomics               |
|         5 | Electrical Engineering Technician | California, CA     | Prom Curt             |
+-----------+-----------------------------------+--------------------+-----------------------+
11 rows in set (0.00 sec)

mysql> SELECT * FROM tableC;
+-----------+---------------+----------------------------+--------------+
| tableA_ID | HOME_TOWN     | HOME_ADDRESS               | HOME_PHONE   |
+-----------+---------------+----------------------------+--------------+
|         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
+-----------+---------------+----------------------------+--------------+
2 rows in set (0.00 sec)

Selecting people with work history:

SELECT tableA.*, tableB.*
FROM tableA, tableB
WHERE tableA.ID = tableB.tableA_ID

mysql> SELECT tableA.ID, tableA.NAME, tableB.tableA_ID, tableB.WORK_TITLE, tableB.WORK_PLACE FROM tableA, tableB WHERE tableA.ID = tableB.tableA_ID;
+----+----------+-----------+-----------------------------------+--------------------+
| ID | NAME     | tableA_ID | WORK_TITLE                        | WORK_PLACE         |
+----+----------+-----------+-----------------------------------+--------------------+
|  1 | Nicholas |         1 | Account Supervisor                | Massachusetts, MA  |
|  1 | Nicholas |         1 | Office Manager                    | Nevada, NV         |
|  1 | Nicholas |         1 | Office Supervisor                 | New York, NY       |
|  1 | Nicholas |         1 | Director Accounts                 | Florida, FL        |
|  1 | Nicholas |         1 | Director Distribution             | Delaware, DE       |
|  2 | Marry    |         2 | Director Office Management        | Montana, MT        |
|  2 | Marry    |         2 | Distribution Director             | North Carolina, NC |
|  3 | Rise     |         3 | EEO Manager                       | Michigan, MI       |
|  5 | Thomas   |         5 | Electrician Maintenance           | South Dakota, SD   |
|  5 | Thomas   |         5 | Electrician Maintenance           | Tennessee, TN      |
|  5 | Thomas   |         5 | Electrical Engineering Technician | California, CA     |
+----+----------+-----------+-----------------------------------+--------------------+
11 rows in set (0.00 sec)

N.B. Unfortunately this query does not give you people from tableA that do not have records in tableB, this can be done with LEFT JOIN … ON

SELECT *
FROM tableA
LEFT JOIN tableB ON tableA.ID = tableB.tableA_ID

mysql> SELECT * FROM tableA LEFT JOIN tableB ON tableA.ID = tableB.tableA_ID;
+----+----------+------------+-----------+-----------------------------------+--------------------+-----------------------+
| ID | NAME     | SURNAME    | tableA_ID | WORK_TITLE                        | WORK_PLACE         | WORK_NAME             |
+----+----------+------------+-----------+-----------------------------------+--------------------+-----------------------+
|  1 | Nicholas | Petman     |         1 | Account Supervisor                | Massachusetts, MA  | New ResearchTecno     |
|  1 | Nicholas | Petman     |         1 | Office Manager                    | Nevada, NV         | Kombaners Networks    |
|  1 | Nicholas | Petman     |         1 | Office Supervisor                 | New York, NY       | Delta Office          |
|  1 | Nicholas | Petman     |         1 | Director Accounts                 | Florida, FL        | Florida Main Company  |
|  1 | Nicholas | Petman     |         1 | Director Distribution             | Delaware, DE       | Cofice Three United   |
|  2 | Marry    | Luddington |         2 | Director Office Management        | Montana, MT        | Hills Sky Limited     |
|  2 | Marry    | Luddington |         2 | Distribution Director             | North Carolina, NC | Brassel Foods Network |
|  3 | Rise     | Courtenay  |         3 | EEO Manager                       | Michigan, MI       | Clear Water Eng.      |
|  4 | Anna     | Borges     |      NULL | NULL                              | NULL               | NULL                  |
|  5 | Thomas   | Hulme      |         5 | Electrician Maintenance           | South Dakota, SD   | Serdsc Inc.           |
|  5 | Thomas   | Hulme      |         5 | Electrician Maintenance           | Tennessee, TN      | Joomics               |
|  5 | Thomas   | Hulme      |         5 | Electrical Engineering Technician | California, CA     | Prom Curt             |
+----+----------+------------+-----------+-----------------------------------+--------------------+-----------------------+
12 rows in set (0.00 sec)

And now tableC, 2 records for one person from tableA:

mysql> SELECT * FROM tableC;
+-----------+---------------+----------------------------+--------------+
| tableA_ID | HOME_TOWN     | HOME_ADDRESS               | HOME_PHONE   |
+-----------+---------------+----------------------------+--------------+
|         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
+-----------+---------------+----------------------------+--------------+
2 rows in set (0.00 sec)

The pure SELECT query on 3 tables, gives results only for people from tableA, who are presented in both, tableB & tableC

SELECT tableA.*, tableB.*, tableC.*
FROM tableA, tableB, tableC
WHERE tableA.ID = tableB.tableA_ID
AND tableA.ID = tableC.tableA_ID

mysql> SELECT tableA.*, tableB.*, tableC.* FROM tableA, tableB, tableC WHERE tableA.ID = tableB.tableA_ID
    -> AND tableA.ID = tableC.tableA_ID;
+----+----------+---------+-----------+-----------------------+-------------------+----------------------+-----------+---------------+----------------------------+--------------+
| ID | NAME     | SURNAME | tableA_ID | WORK_TITLE            | WORK_PLACE        | WORK_NAME            | tableA_ID | HOME_TOWN     | HOME_ADDRESS               | HOME_PHONE   |
+----+----------+---------+-----------+-----------------------+-------------------+----------------------+-----------+---------------+----------------------------+--------------+
|  1 | Nicholas | Petman  |         1 | Account Supervisor    | Massachusetts, MA | New ResearchTecno    |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman  |         1 | Account Supervisor    | Massachusetts, MA | New ResearchTecno    |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman  |         1 | Office Manager        | Nevada, NV        | Kombaners Networks   |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman  |         1 | Office Manager        | Nevada, NV        | Kombaners Networks   |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman  |         1 | Office Supervisor     | New York, NY      | Delta Office         |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman  |         1 | Office Supervisor     | New York, NY      | Delta Office         |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman  |         1 | Director Accounts     | Florida, FL       | Florida Main Company |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman  |         1 | Director Accounts     | Florida, FL       | Florida Main Company |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman  |         1 | Director Distribution | Delaware, DE      | Cofice Three United  |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman  |         1 | Director Distribution | Delaware, DE      | Cofice Three United  |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
+----+----------+---------+-----------+-----------------------+-------------------+----------------------+-----------+---------------+----------------------------+--------------+
10 rows in set (0.00 sec)

N.B. result are duplicated as: tableB occurrences * tableC occurrences for each person in tableA
LEFT JOIN … ON also will be duplicated

SELECT tableA.*, tableB.*, tableC.*
FROM tableA
LEFT JOIN tableB ON tableA.ID = tableB.tableA_ID
LEFT JOIN tableC ON tableA.ID = tableC.tableA_ID;

mysql> SELECT tableA.*, tableB.*, tableC.*  FROM tableA LEFT JOIN tableB ON tableA.ID = tableB.tableA_ID LEFT JOIN tableC ON tableA.ID = tableC.tableA_ID;
+----+----------+------------+-----------+-----------------------------------+--------------------+-----------------------+-----------+---------------+----------------------------+--------------+
| ID | NAME     | SURNAME    | tableA_ID | WORK_TITLE                        | WORK_PLACE         | WORK_NAME             | tableA_ID | HOME_TOWN     | HOME_ADDRESS               | HOME_PHONE   |
+----+----------+------------+-----------+-----------------------------------+--------------------+-----------------------+-----------+---------------+----------------------------+--------------+
|  1 | Nicholas | Petman     |         1 | Account Supervisor                | Massachusetts, MA  | New ResearchTecno     |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman     |         1 | Account Supervisor                | Massachusetts, MA  | New ResearchTecno     |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman     |         1 | Office Manager                    | Nevada, NV         | Kombaners Networks    |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman     |         1 | Office Manager                    | Nevada, NV         | Kombaners Networks    |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman     |         1 | Office Supervisor                 | New York, NY       | Delta Office          |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman     |         1 | Office Supervisor                 | New York, NY       | Delta Office          |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman     |         1 | Director Accounts                 | Florida, FL        | Florida Main Company  |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman     |         1 | Director Accounts                 | Florida, FL        | Florida Main Company  |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  1 | Nicholas | Petman     |         1 | Director Distribution             | Delaware, DE       | Cofice Three United   |         1 | Niagara Falls | 3109 Witmer Road, NY 15305 | 715-88-1822  |
|  1 | Nicholas | Petman     |         1 | Director Distribution             | Delaware, DE       | Cofice Three United   |         1 | Charlotte     | 3141 Piper Lane, NC. 28208 | 212-713-2355 |
|  2 | Marry    | Luddington |         2 | Director Office Management        | Montana, MT        | Hills Sky Limited     |      NULL | NULL          | NULL                       | NULL         |
|  2 | Marry    | Luddington |         2 | Distribution Director             | North Carolina, NC | Brassel Foods Network |      NULL | NULL          | NULL                       | NULL         |
|  3 | Rise     | Courtenay  |         3 | EEO Manager                       | Michigan, MI       | Clear Water Eng.      |      NULL | NULL          | NULL                       | NULL         |
|  4 | Anna     | Borges     |      NULL | NULL                              | NULL               | NULL                  |      NULL | NULL          | NULL                       | NULL         |
|  5 | Thomas   | Hulme      |         5 | Electrician Maintenance           | South Dakota, SD   | Serdsc Inc.           |      NULL | NULL          | NULL                       | NULL         |
|  5 | Thomas   | Hulme      |         5 | Electrician Maintenance           | Tennessee, TN      | Joomics               |      NULL | NULL          | NULL                       | NULL         |
|  5 | Thomas   | Hulme      |         5 | Electrical Engineering Technician | California, CA     | Prom Curt             |      NULL | NULL          | NULL                       | NULL         |
+----+----------+------------+-----------+-----------------------------------+--------------------+-----------------------+-----------+---------------+----------------------------+--------------+
17 rows in set (0.00 sec)





flex 4 viewStack page navigation – part one

This is how to organize flex 4 application with multiple pages, linking between them and some other stuff! Demo, right click to view source.

1. Create flex application.
2.¬†Create ViewStack Component in the main mxml file with some id – mine is “mainViewstack”.

<mx:viewstack id="mainViewstack" left="220" right="10" top="10" bottom="10">
    <s:navigatorcontent width="100%" height="100%"
            label="NavigatorContent: internal page" backgroundColor="#FF0000">
        <s:label left="10" top="10" fontWeight="bold"
            text="NavigatorContent: internal page"></s:label>
    </s:navigatorcontent>
</mx:viewstack>

3. Create LinkBar Component in the main mxml file and link it to the ViewStack (this is just to easy navigate with the ViewStack).

<mx:linkbar left="10" top="10" bottom="10" width="200" dataProvider="{mainViewstack}"
            direction="vertical">
</mx:linkbar>

Continue reading