Archive for the ‘PHP Stuff’ Category

get user system IP in php

Posted: April 7, 2010 in PHP Stuff

$userip = getenv(“REMOTE_ADDR”);

<a href="ExcelSheetReport.xls”> [Download Report In Excel]


$str=”

S. No.

“;

Generate_ExcelReport($str);

function Generate_ExcelReport($htmlFile)
{
echo(”
“);

@session_start();
$sess_id=session_id();

$File_name=”ExcelSheetReport”.$sess_id.”.xls”;
//*************If File is already exist then delete from server
if(file_exists($File_name))
{
unlink($File_name);
}
///////////////////////////////////////////////////////////////
// echo(“
file name is “.$htmlFile); exit;
$handle=fopen($File_name,”w”);
fwrite($handle,$htmlFile);
fclose($handle);

unset($htmlFile);
// ob_flush(); //totka 1
// clearstatcache(); //totka 2
// Header(“Cache-Control: No-cache, Must-revalidate”); //totka 3

//session_destroy();

# require(“pdf/html2fpdf.php”);
# $pdf = new HTML2FPDF(‘L’, ‘mm’, ‘A4’);
# $pdf->AddPage();
# $pdf->WriteHTML($htmlFile);
# $pdf->Output(‘ExamSectionReport.pdf’, ‘F’);
}

function getpasslength()
{
var len = document.getElementById(“pass”).value.length ;
if (len < 4)
{
alert("Password Should be greater then 4 Chars.")
myform.pass.focus();
}
}

get total records

Posted: April 3, 2010 in PHP Stuff
Tags:

function isDepartment()
{
$query = “select * from DepartmentMaster where removed!=’Y'”;
$results = mysql_query($query);
$Count = mysql_num_rows($results);
return $Count;
}

$sql = “show tables”;
$query = mysql_query($sql);
echo “

";
		
	  while($arr = mysql_fetch_array($query))
	  {	
			$key = $arr[0];
  		$sql1 = "SELECT * FROM $key";
			$query1 = mysql_query($sql1);
			if($query1)
			{
				$columns1 = mysql_num_fields($query1);
			

				for($i1 = 0; $i1 < $columns1; $i1++) 
				{
	  			//$arra[$key][] = mysql_field_name($query1,$i1);
					  $fieldStr = mysql_field_name($query1,$i1);  			
					  if(strstr($fieldStr, 'dep'))
					  {
			  			$arra[$key][] = $fieldStr;
						}
				} 
			}
		}
		print_r	($arra);

Sort Array

Posted: April 2, 2010 in PHP Stuff

sort($TableSrc);

Date formating

Posted: April 2, 2010 in PHP Stuff

$Date = date(“Y-m-d”);