Jump to content

PravinS

Members
  • Posts

    459
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by PravinS

  1. Try this

    <?PHP
    $res = mysql_query("SELECT id, DATE_FORMAT(date, '%S %D %Y') as dt, firstname, lastname, testimonial FROM testimonials ORDER BY date DESC LIMIT 10");
    
    while ($row = mysql_fetch_assoc($res)) {
    	echo "<b>{$row['firstname']} {$row['lastname']}</b><br />on {$row['dt']}<br />{$row['testimonial']}<br /><br />";
    }
    ?>
    

     

    If "date" is you field name then it should work.

  2. You can use this function

     

    function force_download($file)
    {
    $dir = "";
    if ((isset($file))&&(file_exists($dir.$file))) 
    {
       header("Content-type: application/force-download");
       header('Content-Disposition: inline; filename="' . $dir.$file . '"');
       header("Content-Transfer-Encoding: Binary");
       header("Content-length: ".filesize($dir.$file));
       header('Content-Type: application/octet-stream');
       header('Content-Disposition: attachment; filename="' . $file . '"');
       readfile("$dir$file");
    }
    }      
    

     

  3. Use below given functions

     

    function select_row($sql)
    {
    //echo $sql . "<br />";
    if ($sql!="")
    {
    	$result = mysql_query($sql) or die("Error: ".mysql_errno().":- ".mysql_error());
    	if ($result)
    	{
    		while($row = mysql_fetch_assoc($result))
    			$data[] = $row;
    	}
    	return $data;
    }
    }
    
    function pagingSlot($sql, $recperpage, $pagesetlimit, $page, $class, $getvars)
    {
    $rescnt=mysql_query($sql);
    $totcnt=mysql_num_rows($rescnt);
       
    	if (!$page)   
    		$page = 1;
    	$first=(($page-1)* $recperpage);
    
    	$sql = $sql . " limit ".$first.",".$recperpage;
    	$res = select_row($sql);
       
    	$serial_no = ($page - 1) * $recperpage;
       
    	$t = ($totcnt/$recperpage);
    	$arr=split('[.]',$t);
    	if ($arr[1])
    		$totalpages=$arr[0]+1;
    	else
    		$totalpages=$arr[0];
       
    	if ($totalpages > $pagesetlimit)
    	{
    		if ($page > 1)
    			$pagesetstart = $page - 1;
    		else
    			$pagesetstart = $page;               
    		   
    		$pagesetend= ($pagesetstart-1) + $pagesetlimit;
    		if ($pagesetend > $totalpages)
    		{
    			$pagesetend = $totalpages;
    			$pagesetstart = $pagesetend - $pagesetlimit + 1;
    		}
    	}
    	else
    	{
    		$pagesetstart = 1;
    		$pagesetend = $totalpages;
    	}
       
    	$str = "";
    
    	if ($page > 1)
    	{
    		$prev = $page - 1;
    		$str.= "<a href='".$_SERVER['PHP_SELF']."?page=$prev".$getvars."'  class='".$class."'> << </a> | ";                                           
    	}
    	else
    	{
    		$str.= "<<  | ";   
    	}
    
    
    	for ($i=$pagesetstart; $i<=$pagesetend; $i++)
    	{       
       
    		if ($i <= $totalpages)
    		{
    			if (!$page)
    				$page=1;
    			if ($page==$i)
    				$str.= '<font color=red>'.$i.'</font> ';
    			else
    				$str.= "<a href='".$_SERVER['PHP_SELF']."?page=$i".$getvars."'  class='".$class."'>".$i."</a> ";
    		}                               
    	}
    
    	if ($page < $totalpages)
    	{
    		$next = $page + 1;
    		$str.= " | <a href='".$_SERVER['PHP_SELF']."?page=$next".$getvars."'  class='".$class."'> >> </a> ";                                           
    	}
    	else
    	{
    		$str.= " |  >>  ";
    	}
    
    if ($totcnt == 0)
    	$str = "";
       
    $arr["records"]=$res;
    $arr["link"]=$str;
    $arr["serial"]=$serial_no;
    return $arr;
    }        
    

  4. Hi

     

    Please use below given function

     

    
    function pagingPN($sql, $page, $limit, $getvars, $class)
    {
    	if ($page == "")
    		$page = 1;
    	if ($limit == 0)
    		$limit = $this->limit;
    	$tsql = $sql;
    	$result = mysql_query($tsql) or die("Error: ".mysql_errno().":- ".mysql_error());
    	$total = mysql_num_rows($result);
    	$totnumpages = ceil($total/$limit);
    	if ($offset < 0)
    		$offset = 0;
    	else          
    		$offset = ($page - 1) * $limit;
    	$sql = $sql. "  limit $offset, $limit"; 
    
    	if ($sql!="")
    	{
    		$result = mysql_query($sql) or die("Error: ".mysql_errno().":- ".mysql_error());
    		if ($result)
    		{
    			while($row = mysql_fetch_array($result))
    				$data[] = $row;
    		}
    		$res = $data;
    		$serial_no = ($page - 1) * $limit;
    		if ($total > 0)
    		{
    			$link .= "<font face='verdana' size='1'>Page: <strong>".$page."</strong> of <strong>".$totnumpages."</strong>   Goto: </font>";
    
    			if ($page > 1)
    			{
    				$link .= "<a href=".$_SERVER['PHP_SELF']."?page=1$getvars class='".$class."' title='Jump to First Page'><<</a> | ";
    				$prev = $page - 1;
    				$link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$prev."$getvars class='".$class."' title='Goto Previous Page'>Previous</a><span class='".$class."'> | </span>";
    			}
    			else
    			{
    				$link .= "<span class='".$class."' title='Jump to First Page'><<</span> | <span class='".$class."' title='Goto Previous Page'>Previous | </span>";
    			}
    			if ($page < $totnumpages)
    			{
    				$next = $page + 1;
    				$link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$next."$getvars class='".$class."' title='Goto Next Page'>Next</a> | ";
    				$link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$totnumpages."$getvars class='".$class."' title='Jump to Last Page'>>></a>";
    			}
    			else
    			{
    				$link .= "<span class='".$class."' title='Goto Next Page'>Next</span> | <span class='".$class."' title='Jump to Last Page'>>></span>";
    			}
    		}		
    		$retarr["sql"] = $sql;
    		$retarr["records"] = $res;
    		$retarr["serial_no"] = $_no;
    		$retarr["link"] = $link;
    		return $retarr;
    	}
    }
    
    $rs =  pagingPN($query, trim($_REQUEST['page']), 10, "", "pagingCSS");
    $rs_recordset = $rs['records'];
    $link = $rs['link'];
    
    

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.