Remove index.php from Codeigniter URL

By default Codeigniter URL may look like http://www.example.com/index.php/controller/method.

To change this to seo friendly like  http://www.example.com/controller/method we have to do some changes in .htaccess.

1.Create .htaccess file in the root and place the below code

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2.Dont forget to enable rewrite_module in apache modules if you didnt enabled it yet.To enable it goto WAMP->Apache->Apache modules->rewrite_module

3.In the config file change index_change to empty

$config['index_page'] ="";

Also change

$config['rewrite_short_tags'] = TRUE;

Inserting comma separated values in to individual rows in MS SQL


	DECLARE @String_Pos int,@String_Len int,@String_Cont nvarchar(100),@CommaSeparatedValues nvarchar(max)
	SET @CommaSeparatedValues='1|2|3|4|5|6|7|8'

	SELECT @String_Pos=0
	SELECT @CommaSeparatedValues = @CommaSeparatedValues + '|'

	WHILE CHARINDEX('|',@CommaSeparatedValues) > 1
	BEGIN
		SELECT @String_Pos=CHARINDEX('|',@CommaSeparatedValues)
		SELECT @String_Cont = RTRIM(SUBSTRING(@CommaSeparatedValues,1,@String_Pos-1))
		INSERT INTO TABLE(CommaSeparatedValue) VALUES(@String_Cont)
		SELECT @String_Len = LEN(@CommaSeparatedValues)
		SELECT @CommaSeparatedValues=SUBSTRING(@CommaSeparatedValues,@String_Pos+1,@String_Len)
	END

DEMO

Sql Cursor

A cursor is a temporary work area created in the system memory when a SQL statement is executed. A cursor contains information on a select statement and the rows of data accessed by it.

EXAMPLE:

DECLARE @ID int,@Name varchar(50)
DECLARE CursorVar CURSOR LOCAL FOR SELECT ID,Name FROM TABLE 
OPEN CursorVar
	FETCH NEXT FROM CursorVar into @ID,@Name
	WHILE @@FETCH_STATUS = 0
	BEGIN
	    SELECT @ID,@Name	 
		FETCH NEXT FROM CursorVar into @ID,@Name
	END 
CLOSE CursorVar
DEALLOCATE CursorVar

Quarterly,halfyearly,annual year based month day dropdown using jQuery

Working Demo

HTML
Period
<select id="test">
 <option value="0">Select</option>
 <option value="1">Monthly</option>
 <option value="2">Quarterly</option>
 <option value="3">Halferly</option>
 <option value="4">Annualy</option>
</select>
<div id="MonthDayDynamicBlock"></div>

jQuery


$("#test").change(function () {
 CreateMonthDayBlock($(this).val(), "#MonthDayDynamicBlock");
 $(".month").change(function () {
 var Month = $(this).val();
 var divid = $(this).parent("div").attr('id');
 CreateDayDrop("#" + divid, Month, "Day");
 });
});

function CreateMonthDayBlock(Period, DivBlock) {
 var MonthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
 var TotalSelect;
 var TotalOption;
 var RemoveOption;
 var StartRemoveOption;
 var EndRemoveOption;
 var SelectOptionArray = [];
 var RemoveOptionArray = [];
 var Monthval;

$(DivBlock).find("div").remove();
 if (Period == 1) {
 $(DivBlock).append("<div id='MonthDayBlock' class='MonthDayEachBlock divblock paddingbotomfivepx'></div>");
 CreateDayDrop("#MonthDayBlock", 0, "Day");
 }
 if (Period == 2) {
 TotalSelect = 4;
 }
 if (Period == 3) {
 TotalSelect = 2;
 }
 if (Period == 4) {
 TotalSelect = 1;
 }
 TotalOption = (MonthNames.length / TotalSelect);
 RemoveOption = MonthNames.length - TotalOption;

if (Period > 1) {
 for (var i = 1; i <= TotalSelect; i++) {
 $(DivBlock).append("<div id='MonthDayBlock" + i + "' class='MonthDayEachBlock divblock paddingbotomfivepx'></div>");
 CreateMonthBlock("#MonthDayBlock" + i, MonthNames, "Month");
 EndRemoveOption = i * TotalOption;
 StartRemoveOption = (EndRemoveOption - TotalOption) + 1;

SelectOptionArray = [];
 for (var j = StartRemoveOption; j <= EndRemoveOption; j++) {
 SelectOptionArray.push(j);
 }
 RemoveOptionArray = [];
 $.each(MonthNames, function (ikey, val) {
 if ($.inArray(ikey + 1, SelectOptionArray) < 0) RemoveOptionArray.push(ikey + 1);
 });

$.each(RemoveOptionArray, function (indexa, valuea) {
 $("#MonthDayBlock" + i + " select.month option[value=" + valuea + "]").remove();

});

CreateDayDrop("#MonthDayBlock" + i, SelectOptionArray[0], "Day");
 }
 }

}

function CreateMonthBlock(MonthDayBlock, MonthNames, Text) {
 var month_select = $("<select class='month floatleft'></select>");
 $.each(MonthNames, function (index, value) {
 var keynum = index + 1;
 month_select.append($('<option></option>').val(keynum).html(value));
 });
 $(MonthDayBlock).append(month_select);
 $(MonthDayBlock).find(".monthtext").remove();
 $(MonthDayBlock).find(".month").before("<div class='monthtext floatleft paddingsidefivepx'>" + Text + "</div>");

}

function CreateDayDrop(MonthDayBlock, Month, Text) {
 if (Month != 0 || Month != "") {
 $(MonthDayBlock).find(".day").remove();
 var dd = new Date(2012, Month, 0);
 var lastday = dd.getDate();
 var day_select = $("<select class='day floatleft'></select>");
 for (var i = 1; i <= lastday; i++) {
 day_select.append($('<option></option>').val(i).html(i));
 }
 $(MonthDayBlock).find(".month").after(day_select);
 $(MonthDayBlock).find(".daytext").remove();
 $(MonthDayBlock).find(".day").before("<div class='daytext floatleft paddingsidefivepx'>" + Text + "</div>");
 } else {
 $(MonthDayBlock).find(".day").remove();
 var day_select = $("<select class='day floatleft'></select>");
 for (var i = 1; i <= 31; i++) {
 day_select.append($('<option></option>').val(i).html(i))
 }
 $(MonthDayBlock).append(day_select);
 $(MonthDayBlock).find(".daytext").remove();
 $(MonthDayBlock).find(".day").before("<div class='daytext floatleft paddingsidefivepx'>" + Text + "</div>");
 }
}

CSS

.MonthDayEachBlock {
 width:100%;
 float:left;
}
.monthtext, .daytext, .month, .day {
 float:left;
}
.monthtext, .daytext {
 padding:0 5px;
}
select.month {
 width:100px;
}

Working Demo

Disable Button After First Click to Prevent Second Click

Javascript


<script language="javascript" type="text/javascript">
    function disableButton(sender,group)
    {
        Page_ClientValidate(group);
        if (Page_IsValid)
        {
            sender.disabled = "disabled";
            __doPostBack(sender.name, '');
        }
    }
</script>

HTML


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ValidationGroup="i"
          ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>&nbsp;<br />
    <asp:Button runat="server" ID="btnSave" Text="Save" OnClick="Save" OnClientClick="disableButton(this,'i')" UseSubmitBehavior="false" ValidationGroup="i" />

For Further Clarfication Click Here
Courtesy : Yasser Zaid