Version 1.0.0
It's simple the way SIMPLE should be.
Simple-ConnectDB is a quick and simple way to put any basic mySql database on line.
Simply edit the pre made db_Config.php template with your settings
For a basic database, about 5 minutes and Whow! it's on line
All that is needed to put it online are these five(5) lines
$db_user = ´root´; $db_password = ´muffin´; $db_Name = ´sakila´; $db_Table = ´customer´; $db_port = ´3307´; //optional
This will display all Records, all Fields and a View link to view that Record
I built this application using Bootstrap, Xpeditable, TableSorter and fancybox along with meekroDB for the mySQL connection. (still needed is meekroDB implemented on the add new record, I had to use the old mySQL connection type until I can figure this out.
Please see their web sites for the license and rights for your use.
This is only a strat of the options included
For Deatil settings, look at each of them in the Documentation
// Database Connection $db_user = 'user'; $db_password = 'password'; $db_Name = 'a1-sales'; $db_Table = 'customers'; $db_port = '3307'; // Change to match the port # for your mySQL
define('DB_SERVER', 'localhost:3307'); define('DB_USER', 'user'); define('DB_PASS', 'password'); define('DB_NAME', 'a1-sales'); define('DB_TABLE', 'customers');
GO THROUGH EACH SETTING BEFORE YOU START.
THIS WAY YOU WILL KNOW HOW TO SET EACH SETTING WITH THE OTHER SETTINGS
When the setting says OPTIONAL it is not required in the config.
However, if it has an * in front of it like this (*OPTIONAL).
Then it is required for the settings listed below it marked with a bullet like this 1-1 or 1-1
This is the only Required settings to display your project
// Set the mySql connection $db_user = ´user´; $db_password = ´password´; $db_Name = ´a1-sales´; $db_Table = ´customers´; $db_port = ´3307´; // optional(only to connect other than port 3306
$appTitle = ´Customers´;
Options: blue, green, bootstrap, dropbox, dark, ice, black-ice, default and grey
$appTheme = ´green´;
Options = filter, columns, resizable
If Not Set then filter,columns abd resizable are disabled
$db_WidgetOptions = "´filter´, ´resizable´";
%s = string
%i = integer
%d = decimal/double
%ss = search string (string surrounded with % for use with LIKE)
$db_Where = ´LastName=%s,Jones´;
See $db_ColumnSort in the next setting
$db_OrderBy = "CompanyName";
This overrides the $db_OrderBy
0 = 1st columnm, 0 - asc and 1 - desc
This overrides the $db_OrderBy
default = "0,0"
if columns are set in widget then you will get highlighting on the sorted columns.
List in order of the column sorted
example sort on column 3 then column2 column = "[3,0],[2,0]"
$db_ColumnSort = "[2,0],[1,0]";
If not set the default is 10
$db_PageSize = 5;
This is the Page # to start on
$db_StartPage = 0;
any # 1 to etc. and all=2000 rows
$db_PageSelector = "5,10,15,20,50,100,ALL";
Defaults to 1 if not set in config
0 = NO Pager, 1 = Display on Top, 2 = Bottom
$db_Pager = 3;
If not set, than the field names will default to the database field names.
$strFieldNames = "ID,COMPANY,FIRSTNAME,LASTNAME,ADDRESS,CITY,STATE,ZIP";
REQUIRED FOR Inline Edit, Edit Record and Adding New Records.
If not set than all fields are considered text fields.
The ones with four ****´s require $arrSelect or $arrSelect2 settings explained below.
text.
textarea,
email, validation only
date,
combodate,
select, ****
password,
url, validation only
number, 0- etc.
range, slider 0-100
checklist, ****
typeahead, ****
wysihtml5.
select2, ****
$strFieldType = ´text,select,text,typeahead,email,checklist,date,wysihtml5´;
The field must be set to select in $strFieldType (above)
Make sure you define $arrSelect as an array
$arrSelect = array(); // Then set these to the fields you need them on $arrSelect[1] = "{´´: ´Select Company´, ´A1-SALES´: ´A1-SALES´, ´A2-SALES´: ´A2-SALES´, ´A3-SALES´: ´A3-SALES´}"; $arrSelect[12] = "{´´: ´Select Sales Rep´, ´Chuck´: ´Chuck Simple´´Kevin´: ´Kevin Lewis´}"; $arrSelect[16] = "[{value: ´1´, text: ´Level-1´}, {value: ´2´, text: ´Level-2´}, {value: ´3´, text: ´Level-3´}]"; $arrSelect[17] = "[{value: ´Red´, text: ´Red´}, {value: ´White´, text: ´White´}, {value: ´Blue´, text: ´Blue´}}]"; $arrSelectValue[17] = ""; $arrSelect[18] = "{´´: ´Select´, ´Active´: ´Active´, ´Non-Active´: ´Non-Active´, ´Vaccation´: ´Vaccation´}";
$arrSelect[7] = "[{value: ´AL´, text: ´Alabama´},{value: ´AK´, text: ´Alaska´},{value: ´AZ´, text: ´Arizona´},{value: ´AR´, text: ´Arkansas´},{value: ´CA´, text: ´California´},{value: ´CO´, text: ´Colorado´},{value: ´CT´, text: ´Connecticut´},{value: ´DE´, text: ´Delaware´},{value: ´FL´, text: ´Florida´},{value: ´GA´, text: ´Georgia´},{value: ´HI´, text: ´Hawaii´},{value: ´ID´, text: ´Idaho´},{value: ´IL´, text: ´Illinois´},{value: ´IN´, text: ´Indiana´},{value: ´IA´, text: ´Iowa´},{value: ´KA´, text: ´Kansas´},{value: ´KT´, text: ´Kentucky´},{value: ´LO´, text: ´Louisiana´},{value: ´ME´, text: ´Maine´},{value: ´MD´, text: ´Maryland´},{value: ´MA´, text: ´Massachusetts´},{value: ´MI´, text: ´Michigan´},{value: ´MN´, text: ´Minnesota´},{value: ´MS´, text: ´Mississippi´},{value: ´MO´, text: ´Missouri´},{value: ´MT´, text: ´Montana´},{value: ´NE´, text: ´Nebraska´},{value: ´NV´, text: ´Nevada´},{value: ´NH´, text: ´New Hampshire´},{value: ´NJ´, text: ´New Jersey´},{value: ´NM´, text: ´New Mexico´},{value: ´NY´, text: ´New York´},{value: ´ND´, text: ´North Dakota´},{value: ´NC´, text: ´North Carolina´},{value: ´OH´, text: ´Ohio´},{value: ´OK´, text: ´Oklahoma´},{value: ´OR´, text: ´Oregon´},{value: ´PA´, text: ´Pennsylvania´},{value: ´RI´, text: ´Rhode Island´},{value: ´SC´, text: ´South Carolina´},{value: ´SD´, text: ´South Dakota´},{value: ´TN´, text: ´Tennessee´},{value: ´TX´, text: ´Texas´},{value: ´UT´, text: ´Utah´},{value: ´VT´, text: ´Vermont´},{value: ´VA´, text: ´Virginia´},{value: ´WA´, text: ´Washington´},{value: ´WV´, text: ´West Virginia´},{value: ´WI´, text: ´Wisconsin´},{value: ´WY´, text: ´Wyoming´}]"; OR $arrSelectgroups[8] = "includes/groups/groups.php"; //see setting groups below
The # between the [] is the field number
$arrSelectgroups[8] = "includes/groups/groups.php";
Name this file to match the group file name set in the group settings
Save this file in the includes/groups folder
Script outputs data in json format, suitable for ´source´ option in X-editable
<?php sleep(1); $groups = array( array(´value´ => ´37010´, ´text´ => ´ADAMS TN 37010´), array(´value´ => ´37011´, ´text´ => ´ANTIOCH TN 37011´), array(´value´ => ´37012´, ´text´ => ´ALEXANDRIA TN 37012´), array(´value´ => ´37013´, ´text´ => ´ANTIOCH TN 37013´), array(´value´ => ´37014´, ´text´ => ´ARRINGTON TN 37014´), array(´value´ => ´37015´, ´text´ => ´ASHLAND CITY TN 37015´), array(´value´ => ´37016´, ´text´ => ´AUBURNTOWN TN 37016´), array(´value´ => ´37018´, ´text´ => ´BEECHGROVE TN 37018´), array(´value´ => ´37019´, ´text´ => ´BELFAST TN 37019´), array(´value´ => ´37020´, ´text´ => ´BELL BUCKLE TN 37020´), array(´value´ => ´37022´, ´text´ => ´BETHPAGE TN 37022´), array(´value´ => ´37023´, ´text´ => ´BIG ROCK TN 37023´), ); echo json_encode($groups); ?> >
The # between the [] is the field number
This settinf allows you to just Type in the input box and then select that tag
$arrSelect2[20] = "[´html´, ´javascript´, ´css´, ´ajax´]";User can also enter his own tag as well as from the list
OR $arrSelect2[20] = ´[{id: "EN", text: "EN"}, {id: "RU", text: "RU"}, {id: "GB", text: "GB"}]´;
Limits the number of Selection you can have
Makes user enter a character for the selection 1 = User has to enter 1 character 2 = User has to enter 2 character when entering the character a list will be displayed if a character match is made from $arrSelect2 Max # of characters you can enter If user enters more characters than the # set. It tells them to enter less characters and disables the enter option supports ability to add choices automatically as the user is typing into the search field. This is especially convenient in the tagging where the user can quickly enter a number of tags by separating them with a comma or a space. Matches options only if the term appears in the beginning of the string as opposed to anywhere in the string
$MaxSelection2[20] = 2;
17-2 MinInputLength2 in Select2 (OPTIONAL)
$MinInputLength2[20] = 1;
17-3 MaxInputLength2 in Select2 (OPTIONAL)
$MaxInputLength2[20] = 1;
17-4 AutoTokenSeparators2 in Select2 (OPTIONAL)
$AutoTokenSeparators2[20] = 1;
17-5 CustomMatcher22 in Select2 (OPTIONAL)
$CustomMatcher2[20] = "yes";
defaults to 1 to show as Text
0 = Text. 1 = Buttons
$dbButtons = 1;
Defaults to 1 to show link
1 = Alows and shows a link on the right side of the row.
0 = Hide the link and don't allow View Record
$dbCanView =
Defaults to 0 - Can Not Edit Record
Required if you want to edit the record
1 = Alows and shows a link on the right side of the row.
0 = Hide the link and don't allow Edit Record
You can still enable inline editting. See settings for $strDisplayInlineEdit
$dbCanEdit = 1;
Defaults to 0 - Can Not Add New Record
1 = Alows and shows a link on the right side of Pager
0 = Hide the link and don't allow Add Record
$dbCanAdd = 1;
Defaults to 0 - Can Not Delete Record
1 = Alows and shows a link on the right side of the row.
0 = Hide the link and don't allow Delete Record
$dbCanDelete = 1;
Only the path and image name is stored in the database field
The Image Field Name in the database MUST be Named 'IMGPhoto'
This only allows one image per record to be displayed
The next version will allow multi inages
$db_ImageFieldName = "IMGPhoto";
Default is 1 - Must be set if usinf Inline Edit or Child Rows
Note: If $strDisplayList NOT SET IN CONFIG all records will show
If Using a Child Row refer to $db_ChildTemplate and $ChildRowHeader
The Fields on the Child Row must also be fields from the parent $db_Name and $db_Table
This option is great for rows that have many fields
It enables you to still display them in the child row (no inline edit)
Set the Field Display option from the chart below
Note: the 1st Field # is 0
Note: Child Rows are not editable in this version
Note: If not using the Child Row then only use option 0 and 1
0 = No Show
1 = Show on Table List only
2 = Show on Table List as the Link to Child Row
3 = Show on Child Row only
4 = Show on Table List and Child Row
$strDisplayList = "244430333310000000013"
Defaults to 1 - All Fileds Show in View
This allows you to hide certain Fields for security etc.
0 = No Show
1 = Show
$strDisplayView = "01111110001011111111";
This allows you to hide certain Fields for security etc.
Defaults to 1 - All Fields are set as a popup
0 = No Show
1 = Show and is Editable with a popup edit
2 = Show and is Editable with inline edit
3 = Shows but Not Editable
$strDisplayViewEdit = "02112222221221222222"
Defaults to 1 as a popup
0 = Field is not editable
1 = Field is Editable with a popup edit
2 = Field is Editable with inline edit
$strDisplayViewEdit = "02112222221221222222"
Defaults to 1 as a popup
$dbCanEdit = 1; must be enabled for the add link to show
0 = Field is not editable and will not show
1 = Field is Editable with a popup edit
2 = Field is Editable with inline edit
$strDisplayAdd = "02112222222122122222"ot;
$dbCanEdit = 1; must be enabled for this feature
It will Display a red * by the Field Name when Adding a new record
0 = Field is not Required
1 = Field is Required
$strRequired = "01110000000000000000";
Defaults to Sort on all Column
0 = Field is not Sortable
1 = Field is Sortable
$strSortable = "11110011100011011110";0000";
Defaults to No Resize of Columns
0 = Field is not Resizable
1 = Field is Resizable
$strResizable = "11110011100100100000";
Defaults to No Filter
0 = Field has no Filter
1 = Field has Filter
$strFilter = "01110000000000010010";
Defaults to false
true = Filter will hide until mouse is over it
false = Filters always shows
$db_HideFilter = ´true´;
Defaults to TEXT
0 = Filter will be a input text box
1 = Filter will be a select box (values for the select option bome from the data in that column
$strFilterSelect = "01110000000000010010";
Using a Child Row Template is optional
It Requires you to create a Template for the display
Add additional CSS to enhance the looks(optional)
$db_ChildTemplate = "Customers-Child-Template.html";
Name this file to match the $db_ChildTemplate path settings
Save this file in the root of the Simple-ConnectDB main folder
Enclose the Field Name in curley brakets {} Note: the Field names must be exactly as in the database
Note: This Template is an only an example however it is used in this demo
Review Bootstrap for more info on how to build the Template with css
<div class="wrapper"> <div class="row"> <div class="span1"> <img class="img-rounded" src="{IMGPhoto}" width="60"> </div> <div class="span2"> <h5> {ContactFirstName} {ContactLastName}<br> {Address1}<br> {City}, {State} {zip}<br> {Phone} </h5> </div> <div class="span3"> <dl class="dl-horizontal"> <dt>DateEntered</dt><dd>{DateEntered}</dd> <dt>Email</dt><dd>{Email}</dd> <dt>Level</dt><dd>{PriceLevel}</dd> <dt>CreditLimit</dt><dd>{CreditLimit}</dd> </dl> </div> <div class="span3"> <dl class="dl-horizontal"> <dd>{Memo}</dd> </dl> </div> </div> </div>
You can add additional css ti the db_Styles.css located in the assets/css folder
DO NOT alter any of the other css already there, It is needed for the contents of the main application.
you will find /* Child Row CSS */ at the bottom of the db_Styles.css
It already has the class wrapper in it
Note: This Template is only an example, however it is used in the demo
/* Child Row CSS */ .wrapper{ float: left; left: 11.00%; width: 80%; padding:.20%; border: 1px solid #336699; background-color: #ffffff; } /* End Child Row CSS */
This sets the header text for the child row
Not used with the Child-Tenplate
$ChildRowHeader = "SHIP TO";
Sets the popup location for the popup when editting
The field must be set to popup for this feature
0 = top
1 = right
2 = bottom
3 = left
$strPopupPlacement = "012330000000000000003";
Sets the the number of rows to show in a textarea field
The default is 5 rows
The [26] is the field numnber
The 7 = seven rows
$TextareaRows[26] = 7;
You can have muliple date and combodate fields
The date field type in the mySQL database must be set to date
NOTE: Fornat for datepicker and combodate are different
Refer to http://vitalets.github.com/bootstrap-datepicker for the datepicker format options.
ONLY THE SETTINGS LISTED HERE ARE USABLE IN Simple-Connectdb
Field-Type must = date
Tell it what field is the Date Field
The [21] says its field number twenty-one(21)
$DateType[21] = "date";
format for when saving the date field
$DateFormat[21] = "yyyy-mm-dd";
Day of week datepicker starts on
0 = Sunday, 6 = Saturday$DateWeekStart[21] = 0;
$DateStartDate[21] = "2013-01-01";
$DateEndDate[21] = "2015-12-31";
This example disables any date on Sunday and Saturday
$DateWeekDaysDisabled[21] = "0,6";
0 = Calendar(default), 1 = Month then calendar and 2 = year then month then calendar
This example would show the year then the month then the complete calendar to select day
$DateStartView[21] = 2;
Listed are 5 examples for the 5 mySQL date types
The date field in the mySQL database must be set to the correct date type
NOTE: Fornat for datepicker and combodate are different
Refer to http://vitalets.github.com/combodate/#docs for the combodate format options.
ONLY THE SETTINGS LISTED HERE ARE USABLE IN Simple-Connectdb
// COMBODATE DATE ONLY $DateType[13] = "combodate"; $DateFormat[13] = "YYYY-MM-DD"; $ComboDateTemplate[24] = "YYYY/MMMM/DD"; $ComboDateMinYear[24] = '2010'; $ComboDateMaxYear[24] = '2015';
// COMBODATE TIME ONLY $DateType[22] = "combodate"; $DateFormat[22] = "HH:mm"; $ComboDateTemplate[22] = "hh:mm a"; $ComboTimeMinuteStep[22] = 15;
// COMBODATE YEAR ONLY $DateType[23] = "combodate"; $DateFormat[23] = "YYYY"; $ComboDateTemplate[23] = "YYYY"; $ComboDateMinYear[23] = '2010'; $ComboDateMaxYear[23] = '2015';
// COMBODATE DATETIME $DateType[24] = "combodate"; $DateFormat[24] = "YYYY-MM-DD HH:mm"; $ComboDateTemplate[24] = "YYYY/MMMM/DD hh:mm a"; $ComboDateMinYear[24] = '2010'; $ComboDateMaxYear[24] = '2015'; $ComboTimeMinuteStep[24] = 15;
// COMBODATE TIMESTAMP $DateType[25] = "combodate"; $DateFormat[25] = "YYYY-MM-DD HH:mm"; $ComboDateTemplate[25] = "YYYY/MMMM/DD hh:mm a"; $ComboDateMinYear[25] = '2010'; $ComboDateMaxYear[25] = '2015'; $ComboTimeMinuteStep[25] = 15;
Will add more as time goes on
List View
Inline Edit
With Child Row
Add Record
Edit Record
View Record
Post all Issues at Simple-ConnectDB
Update and Customize Simple-ConnectDB project with your own features.
Post Updates and your enhancements at Simple-ConnectDB
We will look at them and if all meets the needs. We will add it and show credit to you for a great addon