Jump to content

tapantor24

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by tapantor24

  1. Friends this is the simple php code.

    <?php
    $dbHost = 'localhost'; // localhost will be used in most cases
    // set these to your mysql database username and password.
    $dbUser = 'root'; 
    $dbPass = '12345';
    $dbDatabase = 'member'; // the database you put the table into.
    $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error());
    
    mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());
    ?>
    <?php
    if(isset($_POST['submit']))
    {
    $sex = $_POST['sex'];
    $district = $_POST['district'];
    $age1 = ($_POST['age1']);
    $age2 = ($_POST['age2']);
    } elseif(isset($_GET['submit'])) 
    {
    $sex = $_GET['sex'];
    $district = $_GET['district'];
    $age1 = ($_GET['age1']);
    $age2 = ($_GET['age2']);
    }
    if ($sex == 'All' && $district == '$district' && $age1 == '$age1' && $age2 == '$age2') {
    $result = mysql_query("select * from user where  (Sex = 'Male') AND (Sex = 'Female') AND (Age BETWEEN  '$age1' AND  '$age2') || (District = '$district') ");
    } else if ($sex == 'Female' && $district == '$district' && $age1 == '$age1' && $age2 == '$age2') {
    $result = mysql_query("select * from user where  (Sex = 'Female')  AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district')");
     } else {
     $result = mysql_query("select * from user where  (Sex = 'Male')  AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district')");
    }
     $rows = mysql_num_rows($result);
     if($rows){
     $i=0;
    ?>
     
    <?php
    
    while($row= mysql_fetch_array($result))
    {
    	//$row['Photo'] = "<img src="/user_image/ . $row['Photo']; ""/>
    	
    ?>
    
    <table width="100%"> 
    
    							<tr width="150" class="label">
                              
                                  <td height="21" colspan="2" > <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">
                                    <div align="left">Sex:  
                                       <?php echo $row['Sex']; ?> 
    								    
                                    </div>
                                  </div>
    							   <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">
                                    <div align="left">District:  
                                       <?php echo $row['District']; ?> 
    								    
                                    </div>
                                  </div>
    
    							  </td>
    						  
                                </tr> 
    							
                                </table>
    
    <?php 
     }}
     ?>
    

    and this is Form code.

    <html>
       <title>My Simple Search Form</title>
    
       <body>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    
    
    
    <tr>
    <td><label>Seeking:</label></td>
        <td> <select name="sex" id="sex" class="box" >
    			  		<option >All</option>
    					<option >Male</option>
    					<option >Female</option>
    					
    					
    			  	</select>*<br class="clearBoth" /></td>
                    </tr>
    
                    <tr>
                    <td><label>District:</label></td>
                    <td><select name="district" id="district" class="box" >
         <option >Dhaka</option>
           	
         <option >Bagerhat</option>";
            
            	
         <option >Bandarnban</option>";
            
            	
    
            
               </select>
               *<br class="clearBoth" /></td>
               </tr>
               <tr>
    	 <td><label> Age:</label></td>
    	 <td> <select name="age1" id="age1" class="box">
    			  		<option >18</option>
    					<option >19</option>
    					<option >20</option>
    					<option >21</option>
    					<option >22</option>
    					<option >23</option>
    					<option >24</option>
    					<option >25</option>
    					<option >26</option>
    					<option >27</option>
    					<option >28</option>
    					<option >29</option>
    					<option >30</option>
    					<option >31</option>
    					<option >32</option>
    					<option >33</option>
    					<option >34</option>
    					<option >35</option>
    			  	</select>* To
    				 <select name="age2" id="age2" class="box">
    			  		<option >35</option>
    					<option >34</option>
    					<option >33</option>
    					<option >32</option>
    					<option >31</option>
    					<option >30</option>
    					<option >29</option>
    					<option >28</option>
    					<option >27</option>
    					<option >26</option>
    					<option >25</option>
    					<option >24</option>
    					<option >23</option>
    					<option >22</option>
    					<option >21</option>
    					<option >20</option>
    					<option >19</option>
    					<option >18</option>
    			  	</select>*<br class="clearBoth" /></td>
    	</tr>
    
    <tr>
    <td colspan="2" align="center"><div><input type="submit" name="submit" value="Search!" />
    </div></td>
    </tr> 
    </form>
    </table>
       </body>
    </html>
    

    Heare everything is working fine but Seaking does not work properly. When I select Male or Female and press submit It show all result, even male and female too.

  2. District is not blank. If i remove all from seeking and pagination code then it's work fine. I think the problem is hear if ( isset ( $_POST [ 'sex' ]))

    {

    $sex = $_POST ['sex' ];

    } elseif( isset ( $_GET ['sex' ]))

    {

    $sex = $_POST ['sex' ];

    }

    if ( isset ( $_POST [ 'district']))

    {

    $district = $_POST ['district' ];

    } elseif( isset ( $_GET ['district' ]))

    {

    $district = $_POST ['district' ];

    }

    if ( isset ( $_POST ['age1' ]))

    {

    $age1 = ( $_POST [ 'age1' ]);

    } elseif( isset ( $_GET ['age1' ]))

    {

    $age1 = ( $_POST [ 'age1' ]);

    }

    if ( isset ( $_POST ['age2' ]))

    {

    $age2 = ( $_POST [ 'age2' ]);

    } elseif( isset ( $_GET ['age2' ]))

    {

    $age2 = ( $_POST [ 'age2' ]);

    } and in queries. but how i solve it?

  3. Hi friends, This is the member searching code which I use in my client's site www.bd5000.com It's have

    Seaking:

    District:

    Age:

    but it's only work on Seaking search function. If you see the form you will understand your self.

    Please see the code and tell me what should fixing?

    The code is::

      <?php
    
    	if(isset($_POST['sex']))
    {
    $sex = $_POST['sex'];
    }elseif(isset($_GET['sex']))
    {
    $sex = $_POST['sex'];
    } 
    
    	if(isset($_POST['district']))
    {
    $district = $_POST['district'];
    }elseif(isset($_GET['district']))
    {
    $district = $_POST['district'];
    } 
    	 
    	 	if(isset($_POST['age1']))
    {
    $age1 = ($_POST['age1']);
    }elseif(isset($_GET['age1']))
    {
    $age1 = ($_POST['age1']);
    } 
    
    	 	if(isset($_POST['age2']))
    {
    $age2 = ($_POST['age2']);
    }elseif(isset($_GET['age2']))
    {
    $age2 = ($_POST['age2']);
    } 
    $perpage = 5;
    	 
    	if(isset($_GET["page"]))
    	 
    	{
    	 
    	$page = intval($_GET["page"]);
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$page = 1;
    	 
    	}
    	 
    	$calc = $perpage * $page;
    	 
    	$start = $calc - $perpage;
    if ($sex == 'All') {
    $result = mysql_query("select * from member where  (Sex = 'Male') || (Sex = 'Female') AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district') Limit $start, $perpage");
    } else if ($sex == 'Female') {
    $result = mysql_query("select * from member where  (Sex = 'Female')  AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district') Limit $start, $perpage");
     } else {
     $result = mysql_query("select * from member where  (Sex = 'Male')  AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district') Limit $start, $perpage");
    }
     $rows = mysql_num_rows($result);
     if($rows){
     $i=0;
    ?>
     
    <?php
    
    while($row= mysql_fetch_array($result))
    {
    	//$row['Photo'] = "<img src="/user_image/ . $row['Photo']; ""/>
    	if ($i%2) {
    			$class = 'row1';
    		} else {
    			$class = 'row2';
    		}
    		
    		$i += 1;
    		$name=$row['FName']." ".$row['LName'];
    ?>
    
    <table width="100%"> 
              
      <tr width="150" class="label">
                                 
        <td width="173" rowspan="3"> <div align="center">
       
    <?php
      if ($row['pd_image'] !='') {
      ?>
        <img src="image/product/<?php echo $row['pd_image']; ?>" width="120 height="118"/>
     <?php
     } else {?>
    
      <img src="image/no-image-small.png" width="120" height="118"/>
    <?php } ?> 
           			
        </div></td>
    <td height="21" colspan="2" > 
    <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">
                                    <div align="left">Name: 
                                      <?php if($name != '') { ?>
    							      <?php echo $name; ?>
    						          <?php }else {
    						
    						echo "N/A";
    						 
    							
    						 } ?>
                                    </div>
                  </div></td>
              </tr> <tr width="150" class="label">
                              
                                  <td height="21" colspan="2" > <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">
                                    <div align="left">Profession:  
                                      <?php if($row['position'] != '') { 
    								 
    								  ?>
    							      <?php echo $row['position']; ?>
    						          <?php }else {
    						
    						echo "N/A";
    						 
    							
    						 } ?> 
                                    </div>
                                  </div></td>
                                </tr> 
    							<tr width="150" class="label">
                              
                                  <td height="21" colspan="2" > <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">
                                    <div align="left">Sex:  
                                       <?php echo $row['Sex']; ?> 
    								    
                                    </div>
                                  </div>
    							   <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">
                                    <div align="left">District:  
                                       <?php echo $row['District']; ?> 
    								    
                                    </div>
                                  </div>
    							                       <div align='right'><a href="detail.php?Id=<?php echo $row['ID'];?>"> View</a></div>
    
    							  </td>
    											  
                                </tr> 
    							
                                </table>
     
     <?php 
     }
     ?>
    
    <?php
    }
    else {
    
    print "<p align='center'>Not find any user on you search. Please try again.</p>";
    
    
    }
    ?>
    <table width="100%" cellspacing="2" cellpadding="2" align="center" >
    	 
    	<tr>
    	 
    	<td align="center">
    	 
    	<?php
    	 
    	if(isset($page))
    	 
    	{
    if ($sex == 'All') {
    $result = mysql_query("select Count(*) As Total from member where  (Sex = 'Male') || (Sex = 'Female') AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district') ");
    
    
    	$rows = mysql_num_rows($result);
    	 
    	if($rows)
    	 
    	{
    	 
    	$rs = mysql_fetch_array($result);
    	 
    	$total = $rs["Total"];
    	 
    	}
    	 
    	$totalPages = ceil($total / $perpage);
    	 
    	if($page <=1 )
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$j = $page - 1;
    	 
    	echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>";
    	 
    	}
    	 
    	for($i=1; $i <= $totalPages; $i++)
    	 
    	{
    	 
    	if($i<>$page)
    	 
    	{
    	 
    	echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>$i</span>";
    	 
    	}
    
    	}
    	 
    	if($page == $totalPages )
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$j = $page + 1;
    	 
    	echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>";
    	 
    	}
    	 
    	}
    	 } else if ($sex == 'Female') {
    $result = mysql_query("select Count(*) As Total from member where  (Sex = 'Female')  AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district') ");
     
     $rows = mysql_num_rows($result);
    	 
    	if($rows)
    	 
    	{
    	 
    	$rs = mysql_fetch_array($result);
    	 
    	$total = $rs["Total"];
    	 
    	}
    	 
    	$totalPages = ceil($total / $perpage);
    	 
    	if($page <=1 )
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$j = $page - 1;
    	 
    	echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>";
    	 
    	}
    	 
    	for($i=1; $i <= $totalPages; $i++)
    	 
    	{
    	 
    	if($i<>$page)
    	 
    	{
    	 
    	echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>$i</span>";
    	 
    	}
    
    	}
    	 
    	if($page == $totalPages )
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$j = $page + 1;
    	 
    	echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>";
    	 
    	}
     
     
     } else {
     $result = mysql_query("select Count(*) As Total from member where  (Sex = 'Male')  AND (Age BETWEEN  '$age1' AND  '$age2') ||  (District = '$district') ");
    
     $rows = mysql_num_rows($result);
    	 
    	if($rows)
    	 
    	{
    	 
    	$rs = mysql_fetch_array($result);
    	 
    	$total = $rs["Total"];
    	 
    	}
    	 
    	$totalPages = ceil($total / $perpage);
    	 
    	if($page <=1 )
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$j = $page - 1;
    	 
    	echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>";
    	 
    	}
    	 
    	for($i=1; $i <= $totalPages; $i++)
    	 
    	{
    	 
    	if($i<>$page)
    	 
    	{
    	 
    	echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>$i</span>";
    	 
    	}
    
    	}
    	 
    	if($page == $totalPages )
    	 
    	{
    	 
    	echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";
    	 
    	}
    	 
    	else
    	 
    	{
    	 
    	$j = $page + 1;
    	 
    	echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>";
    	 
    	}
     
     }	
    	?>
    	 
    	<td>
     
    	</tr>
    	 
    	</table>
    
    
  4. Dear friend, This is running code of my site www.bd5000.com where visitor can search the member. If you will see the search form you will see that only seeking search working and another district and age are not working. I read many topics and many tutorial to solv this problem. Where the problem I don't understand. If you caught the problem please tell me where I miss take. Thanks

  5. Look at this code. This is for member search. Hear are sex, district, ,, age search function but it's only work sex function. I try to fix it but I can't. How can i fix this problem?

     

    <?php

    //allow sessions to be passed so we can see if the user is logged in

    session_start();

     

    //connect to the database so we can check, edit, or insert data to our users table

    include "./include/database.php";

     

    //include out functions file giving us access to the protect() function made earlier

    include "./functions.php";

     

    ?>

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

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

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <!-- TemplateBeginEditable name="doctitle" -->

    <title>Bangladesh Activist Forum</title>

    <meta name="keywords" content="Activist Forum">

    <meta name="keywords" content="Helpline">

    <meta name="keywords" content="Friend ship">

    <meta name="description" content="Bangladesh Activist Forum">

    <!-- TemplateEndEditable -->

    <!-- TemplateBeginEditable name="head" -->

    <!-- TemplateEndEditable -->

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

    </head>

     

    <body>

    <div class="con2">

    <!-- start. header -->

    <?php include("./include/header.php"); ?>

    <!-- end. header -->

    <!-- start. searce_bar -->

    <?php include("./include/searce_bar.php"); ?>

    <!-- end. searce_bar -->

    <br/>

    <div class="container">

    <!-- sidebar1 start -->

    <?php include("./include/side_bar1.php"); ?>

    <!-- end .sidebar1 -->

     

    <div class="content">

    <h1> Your Search result..</h1>

    <?php

     

    if(isset($_POST['sex']))

    {

    $sex = $_POST['sex'];

    }elseif(isset($_GET['sex']))

    {

    $sex = $_GET['sex'];

    }

     

    if(isset($_POST['district']))

    {

    $district = $_POST['district'];

    }elseif(isset($_GET['district']))

    {

    $district = $_GET['district'];

    }

     

    if(isset($_POST['age1']))

    {

    $age1 = ($_POST['age1']);

    }elseif(isset($_GET['age1']))

    {

    $age1 = ($_GET['age1']);

    }

     

    if(isset($_POST['age2']))

    {

    $age2 = ($_POST['age2']);

    }elseif(isset($_GET['age2']))

    {

    $age2 = ($_GET['age2']);

    }

     

     

    //protect the posted value then store them to variables

     

    //$name = protect($_POST['fname']);

     

     

     

     

     

    //$sex = $_POST['sex'];

    //$merital = $_POST['merital'];

    //$district = $_POST['district'];

    //$age1 = protect($_POST['age1']);

    //$age2 = protect($_POST['age2']);

    $perpage = 6;

     

    if(isset($_GET["page"]))

     

    {

     

    $page = intval($_GET["page"]);

     

    }

     

    else

     

    {

     

    $page = 1;

     

    }

     

    $calc = $perpage * $page;

     

    $start = $calc - $perpage;

    if ($sex == 'All') {

    $result = mysql_query("select * from member where (Sex = 'Male') || (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') Limit $start, $perpage");

    } else if ($sex == 'Female') {

    $result = mysql_query("select * from member where (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') Limit $start, $perpage");

    } else {

    $result = mysql_query("select * from member where (Sex = 'Male') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') Limit $start, $perpage");

    }

    $rows = mysql_num_rows($result);

    if($rows){

    $i=0;

    ?>

     

    <?php

     

    while($row= mysql_fetch_array($result))

    {

    //$row['Photo'] = "<img src="/user_image/ . $row['Photo']; ""/>

    if ($i%2) {

    $class = 'row1';

    } else {

    $class = 'row2';

    }

     

    $i += 1;

    $name=$row['FName']." ".$row['LName'];

    ?>

     

     

     

     

     

     

    <table width="100%">

     

     

     

     

     

    <tr width="150" class="label">

     

    <td width="173" rowspan="3"> <div align="center">

     

     

    <?php

    if ($row['pd_image'] !='') {

    ?>

    <img src="image/product/<?php echo $row['pd_image']; ?>" width="120 height="118"/>

    <?php

    } else {?>

     

    <img src="image/no-image-small.png" width="120" height="118"/>

    <?php } ?>

     

     

     

     

     

     

     

     

     

    </div></td>

    <td height="21" colspan="2" >

    <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">

    <div align="left">Name:

    <?php if($name != '') { ?>

    <?php echo $name; ?>

    <?php }else {

     

    echo "N/A";

     

     

    } ?>

    </div>

    </div></td>

    </tr> <tr width="150" class="label">

     

    <td height="21" colspan="2" > <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">

    <div align="left">Profession:

    <?php if($row['position'] != '') {

     

    ?>

    <?php echo $row['position']; ?>

    <?php }else {

     

    echo "N/A";

     

     

    } ?>

    </div>

    </div></td>

    </tr>

    <tr width="150" class="label">

     

    <td height="21" colspan="2" > <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">

    <div align="left">Sex:

    <?php echo $row['Sex']; ?>

     

    </div>

    </div>

    <div align="center" style="font:'Times New Roman', Times, serif; font-size:15px;">

    <div align="left">District:

    <?php echo $row['District']; ?>

     

    </div>

    </div>

    <div align='right'><a href="detail.php?Id=<?php echo $row['ID'];?>"> View</a></div>

     

    </td>

     

     

     

     

     

     

     

    </tr>

     

    </table>

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    <?php

    }

    ?>

     

    <?php

    }

    else {

     

    print "<p align='center'>Not find any user on you search. Please try again.</p>";

     

     

    }

     

     

    //$count++

    /** while ($row = mysql_fetch_array($sql)){

    echo 'ID: '.$row['ID'];

    echo '<br/> First Name: '.$row['FName'];

    echo '<br/> Last Name: '.$row['LName'];

    echo '<br/> Phone: '.$row['Phone'];

    echo '<br/><br/>';

    } **/

     

     

    ?>

     

    <table width="100%" cellspacing="2" cellpadding="2" align="center" >

     

    <tr>

     

    <td align="center">

     

    <?php

     

    if(isset($page))

     

    {

    if ($sex == 'All') {

    $result = mysql_query("select Count(*) As Total from member where (Sex = 'Male') || (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') ");

     

     

    $rows = mysql_num_rows($result);

     

    if($rows)

     

    {

     

    $rs = mysql_fetch_array($result);

     

    $total = $rs["Total"];

     

    }

     

    $totalPages = ceil($total / $perpage);

     

    if($page <=1 )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";

     

    }

     

    else

     

    {

     

    $j = $page - 1;

     

    echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>";

     

    }

     

    for($i=1; $i <= $totalPages; $i++)

     

    {

     

    if($i<>$page)

     

    {

     

    echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>";

     

    }

     

    else

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>$i</span>";

     

    }

     

    }

     

    if($page == $totalPages )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";

     

    }

     

    else

     

    {

     

    $j = $page + 1;

     

    echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>";

     

    }

     

    }

    } else if ($sex == 'Female') {

    $result = mysql_query("select Count(*) As Total from member where (Sex = 'Female') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') ");

     

    $rows = mysql_num_rows($result);

     

    if($rows)

     

    {

     

    $rs = mysql_fetch_array($result);

     

    $total = $rs["Total"];

     

    }

     

    $totalPages = ceil($total / $perpage);

     

    if($page <=1 )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";

     

    }

     

    else

     

    {

     

    $j = $page - 1;

     

    echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>";

     

    }

     

    for($i=1; $i <= $totalPages; $i++)

     

    {

     

    if($i<>$page)

     

    {

     

    echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>";

     

    }

     

    else

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>$i</span>";

     

    }

     

    }

     

    if($page == $totalPages )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";

     

    }

     

    else

     

    {

     

    $j = $page + 1;

     

    echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>";

     

    }

     

     

    } else {

    $result = mysql_query("select Count(*) As Total from member where (Sex = 'Male') AND (Age BETWEEN '$age1' AND '$age2') || (District = '$district') ");

     

    $rows = mysql_num_rows($result);

     

    if($rows)

     

    {

     

    $rs = mysql_fetch_array($result);

     

    $total = $rs["Total"];

     

    }

     

    $totalPages = ceil($total / $perpage);

     

    if($page <=1 )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";

     

    }

     

    else

     

    {

     

    $j = $page - 1;

     

    echo "<span><a id='page_a_link' href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2'>< Prev</a></span>";

     

    }

     

    for($i=1; $i <= $totalPages; $i++)

     

    {

     

    if($i<>$page)

     

    {

     

    echo "<span><a href='search.php?page=$i&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>$i</a></span>";

     

    }

     

    else

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>$i</span>";

     

    }

     

    }

     

    if($page == $totalPages )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";

     

    }

     

    else

     

    {

     

    $j = $page + 1;

     

    echo "<span><a href='search.php?page=$j&sex=$sex&District=$district&Age=$age1&Age=$age2' id='page_a_link'>Next</a></span>";

     

    }

     

    }

    ?>

     

    <td>

     

    </tr>

     

    </table>

     

     

     

     

     

     

     

    <!-- end .content --></div>

    <!-- sidebar2 start -->

    <?php include("./include/side_bar2.php"); ?>

    <!-- end .sidebar2 -->

     

    <!-- end .contain"er --></div>

    <!-- start.footer -->

    <?php include("./include/footer.php"); ?>

    <!-- end .footer -->

    </div>

    </body>

    </html>

  6. Look at this code. This is search function with pagination. I want to use this code in project of my client but problem is that the search result show on first page normally but when i press next button it's going wrong. It's show no category found. I spend many tiime to solve this but result is zero. Pls help me any one to solve thise..

     

    <?php

    //include out functions file giving us access to the protect() function made earlier

     

    include "./include/database.php";

    ?>

     

    <?php

     

    $phone = ($_POST['phone']);

     

    $productsPerRow = 2;

    $perpage = 10;

     

    if(isset($_GET["page"]))

     

    {

     

    $page = intval($_GET["page"]);

     

    }

     

    else

     

    {

     

    $page = 1;

     

    }

     

    $calc = $perpage * $page;

     

    $start = $calc - $perpage;

    $result = mysql_query("SELECT * FROM `bookmark` WHERE `phone` = '$phone' Limit $start, $perpage");

    $rows = mysql_num_rows($result);

    $columnWidth = (int)(100 / $productsPerRow);

    if($rows>0){

    $i=0;

    ?>

     

    <table width='100%' border='0' align='center' cellpadding='5' cellspacing='1' class='bookmark'>

     

     

    <?php

    while($row = mysql_fetch_array($result))

    {

    //$row['Photo'] = "<img src="/user_image/ . $row['Photo']; ""/>

    if ($i % $productsPerRow == 0) {

     

    ?>

    <tr >

    <?php

    }

    $Sub =$row['Sub'];

    $url=$row['Link'];

    $Phone =$row['phone'];

    $info =$row['info'];

    ?>

    <td width="$columnWidth%" >Subject:

    <?php echo $row['Sub'];?><br/>

     

    Link:

    <?php echo $row['Link'];?><br/>

     

     

    Mobile:

    <?php echo $row['phone'];?><br/>

     

    Information: <?php if($info != '') { ?>

    <?php echo $row['info'];?>

    <?php }else {

     

    echo "N/A";

     

     

    } ?>

    </td>

    <?php

    if ($i % $productsPerRow == $productsPerRow - 1) {

    echo '</tr>';

    }

     

    $i += 1;

    }

    if ($i % $productsPerRow > 0) {

    echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '"> </td>';

    }

     

    } else {

    ?>

    No products in this category

    <?php

    }

    ?>

    </table>

     

    <table width="100%" cellspacing="2" cellpadding="2" align="center" >

     

    <tr>

     

    <td align="center">

     

    <?php

     

     

     

    if(isset($page))

     

    {

     

    $result = mysql_query("select Count(*) As Total from bookmark WHERE `phone` = '$phone'");

     

    $rows = mysql_num_rows($result);

     

    if($rows)

     

    {

     

    $rs = mysql_fetch_array($result);

     

    $total = $rs["Total"];

     

    }

     

    $totalPages = ceil($total / $perpage);

     

    if($page <=1 )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Prev</span>";

     

    }

     

    else

     

    {

     

    $j = $page - 1;

     

    echo "<span><a id='page_a_link' href='info5.php?page=$j'>< Prev</a></span>";

     

    }

     

    for($i=1; $i <= $totalPages; $i++)

     

    {

     

    if($i<>$page)

     

    {

     

    echo "<span><a href='info5.php?page=$i' id='page_a_link'>$i</a></span>";

     

    }

     

    else

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>$i</span>";

     

    }

     

    }

     

    if($page == $totalPages )

     

    {

     

    echo "<span id='page_links' style='font-weight:bold;'>Next ></span>";

     

    }

     

    else

     

    {

     

    $j = $page + 1;

     

    echo "<span><a href='info5.php?page=$j' id='page_a_link'>Next</a></span>";

     

    }

     

    }

     

    ?>

     

    <td>

     

    </tr>

     

    </table>

    <form action="info5.php" method="POST">

    <input name="phone" id="phone" type="text" size="25" class="box" value="Type Mobile No…" onfocus="this.value=(this.value=='Type Mobile No…')? '' : this.value ;" />

    <input type="submit" name="submit" class="box" id="submit" value="Search" />

    </form>

×
×
  • 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.