JAIN SONGS LYRICS – tu mane bhagwan ek vardaan aapi de !!
Posted in other
PHP Date ( Archived date list )
<?php
$stDtTimeVar = ’12/30/2010 09:00 PM’;
$endDtTimeVar = ’12/30/2010 09:00 AM’;
echo ‘start date:– ‘.$stDtTimeVar;
echo “<br /> <br />”;
echo ‘end date:– ‘.$endDtTimeVar;
echo “<br /> <br />”;
if(strtotime($stDtTimeVar) >= strtotime($endDtTimeVar)) {
echo ‘start date is greater.’;
}
else {
echo ‘end date is greater.’;
}
echo “<br /> <br />”;
$url = $_SERVER['PHP_SELF'];
$i=1;
$monthLimit=12;
$currentdate = date(“Y-m”, mktime(0,0,0,date(“m”),1,date(“Y”)));
$currentdate1 = str_replace ( “-” , “_” , $currentdate);
$currentdateDisp=date(“F Y”, mktime(0,0,0,date(“m”),1,date(“Y”)));
echo “<a href=’$url?date=$currentdate1′>”.$currentdateDisp.”</a>”.”<br>”;
while($monthLimit > 0) {
$monthVal = date(“m”)-$i;
$dateDisp = date(“Y-m”, mktime(0,0,0,$monthVal,1,date(“Y”)));
$dateDisp1 = str_replace ( “-” , “_” , $dateDisp);
$dateDisp2 = date(“F Y”, mktime(0,0,0,$monthVal,1,date(“Y”)));
?>
<a href=’<?=$url?>?date=<?=$dateDisp1?>’><?=$dateDisp2?></a><br>
<?php
$monthLimit–;
$i=$i+1;
}
?>
Thanks,
Nilesh Prajapati
Posted in php
Marge 2 field Sybase query
TableName: ScheduledHomepage
Fields: startDate (datetime) , startHour (time)
select startDate,startHour from ScheduledHomepage
startDate startHour
————————– —————
NULL NULL
May 15 2010 12:00AM 10:00AM
Mar 11 2010 12:00AM 9:00AM
//Trancate time value from full date time value.
select left(startDate,11) as startDate from ScheduledHomepage
startDate
———–
NULL
May 15 2010
Mar 11 2010
//Combine 2 field value
select left(startDate,11) +” “+ convert(varchar(8), startHour) as startDateTime from ScheduledHomepage
startDateTime
——————–
May 15 2010 10:00AM
Mar 11 2010 9:00AM
Other sample examples:
select convert(nvarchar,getdate(),101)
select convert(INT,convert(varchar,getdate(),112))
SELECT LEFT(DateTimeField, 11) FROM Table
SELECT CONVERT(VARCHAR(20), DateTimeField, 101) FROM YourTable
Thanks,
Nilesh Prajapati
Posted in mysql
Javascript + Array sort on Key
<HTML>
<HEAD>
<TITLE> array key sort </TITLE>
<script language=”javascript”>
jsArray = new Array();
jsArray['A'] = ‘Test1′;
jsArray['Z'] = ‘Test3′;
jsArray['P'] = ‘Test4′;
jsArray['U'] = ‘Test2′;
jsArray['B'] = ‘Test5′;
array = jsArray;
var keys = new Array();
for(k in array)
{
keys.push(k);
}
keys.sort( function (a, b){return (a > b) – (a < b);} );
for (var i = 0; i < keys.length; i++)
{
alert(keys[i] + ” , ” + array[keys[i]]);
}
</script>
</HEAD>
<BODY>
Javascript + Array sort on Key
</BODY>
</HTML>
Posted in javascript
MSSql:convert dd/mm/yyyy (’21/05/2010′) to MMM/dd/YYYY (‘May/21/2010′)?
SELECT REPLACE(convert(varchar(11), getdate(), 109),’ ‘,’/’)
Posted in mysql
.htaccess – some security on site.
File Name: .htaccess – put this on root directory of htdocs folder.
#order deny,allow
#deny from all
#allow from 127.0.0.1
#Options +Indexes # enables Directory listing
#Options –Indexes # disables directory listing
#just create an empty directory list
IndexIgnore *
#to skip all gif, zip and txt files from the directory list
#IndexIgnore *.gif *.zip *.txt
#ErrorDocument 404 /notfound.html
ErrorDocument 404 http://localhost/Nilesh/notfound.html
Thanks, Nilesh
Posted in Web server
php – Cannot modify header information – headers already sent by (php header already sent error)
This error comes when you print any thing before php hreader command or sometime single spaces allowed before any file starting place or printing or getting values from $_COOKIE or $_SESSION or set cookie or set session etc…
Example Error Code:
<?php
print “text”;
header(‘Location: http://www.example.com/’);
?>
Solution :
<?php
function JSRedirection($url)
{?>
<script type=”text/javascript”>
<!–
window.location = “<?=$url?>”
//–>
</script>
<?}
print “test”;
JSRedirection(“http://www.example.com/”);
?>
Above is by use of js redirect function. But we can solved it by php functions only.
Example 1:
<?php
header("location: 1.html");
header("location: 2.html"); //replaces 1.html
?>
This redirects to 2.html since the second header replaces the first.
Example 2:
<?php
header("location: 1.html");
echo "send data";
header("location: 2.html"); //1.html already sent
?>
This redirects to 1.html since the header is sent as soon as the echo happens. You also won't see any "headers already sent" errors because the browser follows the redirect before it can display the error.
Example 3:
<?php
ob_start();
header("location: 1.html");
echo "send data";
header("location: 2.html"); //replaces 1.html
ob_end_flush(); //now the headers are sent
?>
Wrapping the previous example in an output buffer actually changes the behavior of the script! This is because headers aren't sent until the output buffer is flushed.
OR
Need to write <?php ob_start(); ?> at first line of html part when you main body is common for all pages.
like:
<?php ob_start(); ?>
<html> …… <?php include_once “<included part of files >”; ?> …… </html>
Thanks,
Nilesh Prajapati.
Posted in php, Uncategorized
Javascript + Array sort on Key
Hi,
Please follow following example to understand the problem.
<script>
function keySort(array, flag) {
var keys = new Array();
for(k in array) {
keys.push(k);
}
keys.sort( function (a, b) {
if (flag && flag != ‘undefined’) {
if(flag == ‘integer’) {
a = parseInt(a);
b = parseInt(b);
}
}
return (a > b) – (a < b);
} );
return keys;
}//End of function keySort
/*jsArray = new Array();
jsArray['A'] = ‘Test1′;
jsArray['Z'] = ‘Test3′;
jsArray['P'] = ‘Test4′;
jsArray['U'] = ‘Test2′;
jsArray['B'] = ‘Test5′;*/
jsArray = new Array();
jsKeyArray = new Array();
jsArray[80] = ‘nil1′;
jsArray[120] = ‘nil2′;
jsArray[160] = ‘nil3′;
for (x in jsArray) {
alert(x + ‘ –> ‘ + jsArray[x]);
}
jsKeyArray = keySort(jsArray);
/*for (x in jsKeyArray) {
alert(x + ‘ –> ‘ + jsKeyArray[x]);
}*/
//It will display wrong result….
for (var i = 0; i < jsKeyArray.length; i++) {
alert(jsKeyArray[i] + ‘ –> ‘ + jsArray[jsKeyArray[i]]);
}
jsKeyArray = keySort(jsArray, ‘integer’);
//correct result….
for (var i = 0; i < jsKeyArray.length; i++) {
alert(jsKeyArray[i] + ‘ (integer) –> ‘ + jsArray[jsKeyArray[i]]);
}
//——————————————————————–
//Value integer sorting…..
function sortASC(a, b){ return (a-b); }
function sortDESC(a, b){ return (b-a); }
integerArray = new Array(1,545,1435,3453,342,441,90);
integerArray.sort( sortASC );
document.write(‘ <br /> Ascending : ‘ + integerArray);
integerArray.sort( sortDESC );
document.write(‘ <br /> Descending : ‘ + integerArray );
</script>
Thanks,
Nilesh Prajapati
Posted in javascript
How to refresh the parent window on closing the child window ?
Hi,
Demo Example:
1) parent.php
<html>
<head> <title>Parent Window</title>
<script language=”javascript”>
window.name = ‘parentWindow’;
var newPopupWindow;
function popupLinkOption(url,width,height) {
newPopupWindow=window.open(url,”childWindow”,”height=”+height+”,width=”+width+”,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=no”);
}
</script>
</head>
<body>
Parent File <br />
<a href=”#” onclick=”popupLinkOption(‘child.php’,200,200);”> Popup </a>
<?php
if ($_GET['rId']) {
echo “<br />Rendom Id –>”.$_GET['rId'];
}
?>
</body>
</html>
————————————————————————————————
2) child.php
<html>
<head> <title>Child Window</title>
<script language=”javascript”>
function refreshParent() {
//here window.opener is the parent window from which child window opened.
parentURL = window.opener.location.href;
if (parentURL && parentURL != ‘undefined’) {
//alert(window.opener.location.href + ‘ — ‘ + window.opener.location);
//alert(window.opener.name);
parentURLArr = parentURL.split(‘#’);
//find last characters from the string means # as we have href=’#’ in parent window link
//newStr = parentURL.substring(0, parentURL.length-1);
//alert(newStr);
parentURLArr1 = parentURLArr[0].split(‘?rId=’);
//alert(parentURLArr1[0]);
qStr = ‘?rId=’+Math.random(); //random Id added here becuase it will not take page from the browser cache.. sometimes required for some browser.
window.opener.location.href = parentURLArr1[0] + qStr;
//window.opener.location.href = window.opener.location.href; //this also used to refresh the parent window.
//window.opener.location.reload(); //this also we can add to reload the parent window.
//window.opener.close(); //parent open closing
}
}
function closeChild() {
window.close();
}
</script>
</head>
<body onunload=”refreshParent();” >
Child File <br />
<a href=”#” onclick=”closeChild();”> Close Child</a>
</body>
</html>
This is just demo with alert and other things. so, can check in your local pc.. and you can modified code as per your requirements.
Run parent.php file to check this exmple.
Thanks,
Nilesh Prajapati.
Posted in javascript
Javascript function to get particular querystring value from URL.
Hi,
function getQueryStrVal(url,name) {
name = name.replace(/[\[]/,”\\\[").replace(/[\]]/,”\\\]”);
var regexS = “[\\?&]“+name+”=([^&#]*)”;
var regex = new RegExp( regexS );
var results = null;
if (url && url != ‘undefined’) {
results = regex.exec( url );
}
else {
results = regex.exec( window.location.href );
}
if( results == null )
return “”;
else
return results[1];
}
How to use:
here url is your js variable in which your whole url is defined.
if(url.indexOf(‘prefixVal’) != -1) {
prefixVal = getQueryStrVal(url, ‘prefixVal’);
alert(prefixVal);
}
Thanks,
Nilesh prajapati.
Posted in javascript



Recent comments