session pagination in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpjawahar
Forum Newbie
Posts: 19
Joined: Thu Jan 12, 2012 6:06 am
Location: Chennai, India

session pagination in php

Post by phpjawahar »

i am using session concept in pagination.. that working in my local host server but didnt work in my web server .. any body know how to solve....

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php 
ob_start();
session_start();
error_reporting(0);
include("connec.php");
require_once ('pagination.php');
if(($_POST['submit']=="go"))
{

$_SESSION['textfield']=$_POST['textfield']; 
$_SESSION['textfield5']=$_POST['textfield5'];
$_SESSION['textfield3']=$_POST['textfield3'];
$_SESSION['textfield4']=$_POST['textfield4'];



                                                 $doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];
}


				$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]); 
	                                                 $page = ($page == 0 ? 1 : $page);
	                                                 $perpage = 10;//limit in each page
	                                                 $startpoint = ($page * $perpage) - $perpage;
													if($_POST['submit']<>""){
													$_SESSION['textfield']=$_POST['textfield']; 
													 $_SESSION['textfield5']=$_POST['textfield5'];
													 $_SESSION['textfield3']=$_POST['textfield3'];
													$_SESSION['textfield4']=$_POST['textfield4'];
													$doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];
												 //echo $select;
//												 echo $select2;
//												 echo $select3;
													}
													else
													{
												 $doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];
												 
												}												 
									 
?>





<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="images/orange.jpg" />
<title>Find the Hospitals</title>


<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<style type="text/css">
<!--
.row-actions{visibility:hidden;padding:2px 0 0;}

tr:hover .row-actions,div.comment-item:hover .row-actions{visibility:visible;}.row-actions-visible{padding:2px 0 0;}

.pagination {
padding: 3px;
margin: 3px;
text-align:center;
font-size:12px;
}

.pagination a {
padding: 2px 5px 2px 5px;
margin: 2px;
background-color:none;
border: 1px solid #AAAADD;

text-decoration: none; /* no underline */
color: #333333;
}
.pagination a:hover, .digg a:active {
border: 1px solid #d9e8ff;

color: #FF6600;
}
.pagination span.current {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #d9e8ff;

font-weight: bold;
background-color: #d9e8ff;
color: #333333;
}
.pagination span.disabled {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #EEE;

color: #333333;
}

.table_row {
    border-bottom: 0px dotted #AAAAAA;
	}
-->
</style>
<style>
a.selected {
  background-color:#1F75CC;
  color:white;
  z-index:100;
}

.messagepop {
  background-color:#FFFFFF;
  border:1px solid #999999;
  cursor:default;
  display:none;
  margin-top: 15px;
  position:absolute;
  text-align:left;
  width:394px;
  z-index:50;
  padding: 25px 25px 20px;
}


.messagepop p, .messagepop.div {
  border-bottom: 1px solid #EFEFEF;
  margin: 8px 0;
  padding-bottom: 8px;
}

</style>
<script type="text/JavaScript">

var message="NoRightClicking";
function defeatIE() {if (document.all) {(message);return false;}}
function defeatNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=defeatNS;}
else{document.onmouseup=defeatNS;document.oncontextmenu=defeatIE;}
document.oncontextmenu=new Function("return false")
</script>

<link href="css/style_circle10.css"  rel="stylesheet" type="text/css" />

		
</head>

<body ondragstart="return false" onselectstart="return false" oncopy="return false">
<!--<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0" style="box-shadow: 0 0 10px 3px #C8D9E9;border-right: #CCCCCC  1px solid; border-left:#CCCCCC 1px solid">
  <tr>
    <td align="left"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
    <td height="158" style="background:url(images/orange_banner.png) repeat-x">&nbsp;</td>
	  
      </tr>-->
	  <?php include('header.php');?>
      <!--<tr>
	  
        <td><div  class="searchbg"><table width="100%" border="0">
 
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="3%" height="26">&nbsp;</td>
        <td width="22%"><strong>Doctor's name </strong></td>
        <td width="22%"><strong>Specialization</strong></td>
        <td width="21%"><strong>City</strong></td>
        <td width="22%"><strong>Area</strong></td>
        <td width="10%">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="textfield" style="width:170px;" type="text" onfocus="if (this.value==this.defaultValue) this.value='';"  onblur="if (this.value=='') this.value=this.defaultValue;"   value="e.g John " /></td>
        <td><label>
          <input name="textfield5" style="width:170px;" type="text" onfocus="if (this.value==this.defaultValue) this.value='';"  onblur="if (this.value=='') this.value=this.defaultValue;" value="e.g Dentists " />
        </label></td>
        <td><label>
          <input name="textfield3" style="width:170px;" type="text"  onfocus="if (this.value==this.defaultValue) this.value='';"  onblur="if (this.value=='') this.value=this.defaultValue;"value="e.g Chennai " />
        </label></td>
        <td><label>
          <input name="textfield4" style="width:170px;"  onfocus="if (this.value==this.defaultValue) this.value='';"  onblur="if (this.value=='') this.value=this.defaultValue;" type="text" value="e.g Adyar " />
        </label></td>
        <td><label>
          <input class="btn_01" type="submit" name="Search" value="Search" />
        </label></td>
      </tr>
    </table></td>
  </tr>
</table>
 </div></td>
      </tr>-->
	  <?php include('se_field1.php');?>
	  
	 
      <tr>
        <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="15%" height="508" align="left" valign="top" style="padding:0px 0px 0px 0px"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td align="left" valign="top"><img src="images/cdcban.jpg" width="150" height="450" onclick="open_win()" /></td>
              </tr>
              <tr>
                <td><img src="images/global.jpg" width="150" height="150" onclick="open_win2()" /></td>
              </tr>
              <tr>
                <td></td>
              </tr>
            </table></td>
            <td width="70%" align="left" valign="top" style="padding:15px "><div class="divbox1">
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="20" class="headlink"  >Home >Search </td>
                </tr>
                <?php 
	  
				 


 

 

                                                 $doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];
 
											

				
				if($doc_name != '' )
				{	
					$query_add="  hospital_name = '".$doc_name."' ";
				}
				if($cata != '' )
				{	
					$query_add=$query_add." and categories = '".$cata."' ";
				}
				if($city != '' )
				{	
					$query_add=$query_add." and cus_city = '".$city."' ";
				}
				if($area != '' )
				{	
					$query_add=$query_add." and cus_area = '".$area."' ";
				}	
 $doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];

	
			  $search=mysql_query( "SELECT * FROM hospital_details WHERE 1 $query_add order by hospital_name LIMIT 0 , 5");
			//echo  "SELECT * FROM cus_paid WHERE 1 $query_add order by categories LIMIT 0 , 5";
  while($search2=mysql_fetch_array($search))
  {
  ?>
  
  
  <tr>
                <td  style="padding-bottom:5px;"><div  class="searchdiv"><table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="82%" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td align="left" ><span class="head1pre"><?php echo $search2['hospital_name'];?></span> &nbsp;&nbsp;&nbsp;<span class="head2"> <?php echo $search2['categories']; ?></span></td>
        </tr>
      
      <tr>
        <td height="20" align="left" valign="top" class="font11"><strong>Location : </strong><?php echo $search2['cus_address']; ?></td>
      </tr>
    </table>      </td>
    <td width="18%" align="center" valign="middle"><a href="<?php echo $search2['cus_web_address']; ?>" >
      <input type="submit" class="btn_02" name="Submit22" value="View profile" />
    </a></td>
  </tr>
  <tr>
    <td align="center" valign="middle" class="per11">Premium Listing </td>
  </tr>
  
</table>
 </div></td>
              </tr>
  
  
  
  
  
  
  
  
  
  
  
  
  
                
                <?php }?>
                <?php
				
				if(!empty($_POST['submit'] ))
				$doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];

				
				{
				
				if($doc_name != '' )
				{	
					$query_add=" and hospital_name = '".$doc_name."' ";
				}
				if($cata != '' )
				{	
					$query_add=$query_add." and categories = '".$cata."' ";
				}
				if($city != '' )
				{	
					$query_add=$query_add." and cus_city = '".$city."' ";
				}
				if($area != '' )
				{	
					$query_add=$query_add." and cus_area = '".$area."' ";
				}	
				
					
					
		else
		{
		// echo "No Records Are Found";
		}
 	?>
                <?php
  
  
  if($search1 == '')
  {
  
  }
  
  
  $search=mysql_query( "SELECT * FROM hospital_details WHERE 1 $query_add order by categories LIMIT $startpoint , $perpage");
  //echo "SELECT * FROM cus_details WHERE 1 $query_add order by categories LIMIT $startpoint , $perpage";
			$search2="SELECT  COUNT( * ) AS num FROM hospital_details WHERE 1 $query_add order by categories ";
			
			
  while($search1=mysql_fetch_array($search))
  {?>
  
  
  <tr>
                <td  style="padding-bottom:5px;"><div  class="searchdiv"><table width="100%" border="0" cellpadding="0" cellspacing="0">
 
  <tr>
    <td width="82%" rowspan="2" align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
    
      <tr>
        <td class="head2"><span class="head1"> <?php echo $search1['hospital_name'];?></span></td>
      </tr>
      <tr>
        <td class="head2"> <?php echo $search1['categories'];?>,<?php echo $search1['cus_area']; ?>,<?php echo $search1['cus_city']; ?> </td>
      </tr>
     
     
    </table></td>
    <!--<td width="18%" colspan="1" align="center" valign="middle" style="padding-bottom:2px"><a href="<?php /*?>/*<?php echo $search1['cus_web_adDress']; ?>*/ ?>" >
      <input type="submit" class="btn_03" name="Submit2" value="View profile" /></a></td>-->
  </tr>
  <tr>
    <td colspan="1" align="center" valign="middle" style="padding-bottom:2px" class="per11">Free Listing </td>
  </tr>
  
</table>
 </div></td><?php }}?>
                      
              </tr>
  
  
  <tr>
  <td><div class="rdeal_nxt_btn" align="center"  >
                        <?php
		$_SESSION['textfield']=$_POST['textfield']; 
													 $_SESSION['textfield5']=$_POST['textfield5'];
													 $_SESSION['textfield3']=$_POST['textfield3'];
													$_SESSION['textfield4']=$_POST['textfield4'];
													$doc_name=$_SESSION['textfield']; 
												 $cata=$_SESSION['textfield5'];
												 $city=$_SESSION['textfield3'];
												 $area=$_SESSION['textfield4'];
		echo Pages($search,$perpage,"search.php?",$search2);?>
                    </div></td></tr>
  
  
  
  
  
  
  
  
  
  
                
              </table>
            </div></td>
            <td width="15%" align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td align="right" valign="top"><img src="images/miot.jpg" width="150" height="450"  onclick="open_win1()"/></td>
              </tr>
              <tr>
                <td align="right" valign="top"><img src="images/bill.jpg" width="150" height="150" onclick="open_win4()" /></td>
              </tr>
              <tr>
                <td><img src="images/apollo_logo.jpg" width="150" height="150" onclick="open_win3()" /></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <?php include('footer.php');?>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-29026349-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<!-- Start Alexa Certify Javascript -->
<script type="text/javascript" src="https://d31qbv1cthcecs.cloudfront.net/atrk.js"></script><script type="text/javascript">_atrk_opts = { atrk_acct: "5hBcf1aoyn00iE", domain:"findthedoctors.info"}; atrk ();</script><noscript><img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=5hBcf1aoyn00iE" style="display:none" height="1" width="1" alt="" /></noscript>
<!-- End Alexa Certify Javascript -->
</body>
</html>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: session pagination in php

Post by Celauran »

phpjawahar wrote:that working in my local host server but didnt work in my web server
This doesn't really tell us anything. How is it not working? What errors are you encountering?
Post Reply