Saturday, May 31, 2008

Simple paging in php

function prev_pg($current_page,$url)
{
for($i=1;$i<$current_page;$i++)
{
echo " ".$i."|";
}

}
function next_pg($current_page,$url,$total_set,$limits)
{
$total_pages=($total_set/$limits)+1;
for($i=$current_page;$i<=$total_pages;$i++)
{
echo " ".$i."|";
}
}


if(isset($_POST["page_no"]))
$page=$_POST["page_no"];
else
$page=1;
$start=$page-1;
$limits=10;

$sql="SELECT `*` FROM ------------- ";
$name1=mysql_query($sql);
$total_set=mysql_num_rows($name1)




$sql="SELECT -------------------- LIMIT $start ,$limits";
$name=mysql_query($sql);
$row=mysql_fetch_array($name);


prev_pg($page,"tariff.php");
next_pg($page,"tariff.php",$total_set,$limits);

Thursday, May 15, 2008

trim in java script

function LTrim( value ) {

var re = /\s*((\S+\s*)*)/;
return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim( value ) {

var re = /((\s*\S+)*)\s*/;
return value.replace(re, "$1");

}

// Removes leading and ending whitespaces
function trim( value ) {

return LTrim(RTrim(value));

}

Wednesday, May 07, 2008

replace all occurance of particular portion

function replace(string,text,by) {
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;

var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;

var newstr = string.substring(0,i) + by;

if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);

return newstr;
}

dict function

function dict($english)
{
$ini_array = parse_ini_file("d.ini");
return($ini_array[$english]);
}

Sunday, May 04, 2008

header for arabic html page

meta equiv="content-type" content="text/html; charset=windows-1256"
meta equiv="content-language" content="ar">

header for arabic html page

meta equiv="content-type" content="text/html; charset=windows-1256"
meta equiv="content-language" content="ar">

Print a particular div on HTML page

function CallPrint(strid){
var prtContent = document.getElementById(strid);var WinPrint =window.open('','','left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');WinPrint.document.write(prtContent.innerHTML);WinPrint.document.close();WinPrint.focus();WinPrint.print();WinPrint.close();prtContent.innerHTML=strOldOne;}