Membuat penomoran di php

hendra · Aug 26, 2014
Mohon bantuan nya teman2,

Saya ada script yang berfungsi untuk pencariaan data, dan script ini sudah berfungsi baik. Yang menjadi masalah saya, yaitu penomoran yang apabila kita pilih no selanjutnya, akan menampilkan semua data yang ada, bukan data yang berdasarkan pencarian.
Terimakasih untuk bantuannya.

Salam

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

<html>
<head>
<title>HKBP BONANG APLIKASI</title>
<!-- css file included -->
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <link rel="stylesheet" href="css/calendar.css">
  <link rel="stylesheet" href="css/menu-item1.css" media="screen" type="text/css">
  <link rel="stylesheet" href="css/menu-bar1.css" media="screen" type="text/css">
  <link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />
  <link href="static_files/help.css" rel="stylesheet" type="text/css" media="all" />
<!-- css file included end -->

<!-- Java script funct -->
<script language="JavaScript" type="text/javascript">
    function hide(x) { document.getElementById(x).style.display='none'; }
    function show(x) { document.getElementById(x).style.display=''; }
    var GB_ROOT_DIR = "./greybox/";

</script>
<!-- Java script funct end-->

<!-- Java Script Included -->
  <script type="text/javascript" src="js/menu-for-applications.js"></script>
  <script type="text/javascript" src="greybox/AJS.js"></script>
  <script type="text/javascript" src="greybox/AJS_fx.js"></script>
  <script type="text/javascript" src="greybox/gb_scripts.js"></script>
  <script type="text/javascript" src="static_files/help.js"></script>
  <script language="JavaScript" src="js/calendar_us.js"></script>
<!-- Java Script Included end -->



</head>
<center>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (index.psd) -->
<table id="Table_01" width="800" border="0" cellpadding="0" cellspacing="0">
	<tr><td colspan="3">&nbsp;</td></tr>
	<tr>
		<td background="img/img_01.png" width="20" height="53">
		</td>
		<td background="img/img_02.png" width="762" height="53"><h2>HKBP BONANG APPLICATION
		</h2></td>
		<td background="img/img_03.png" width="18" height="53"></td>
	</tr>
	<tr>
        <td colspan="3" width="800">
           <table width="792.5" border="0" align="center" cellpadding="0" cellspacing="0">
             <TR><TD><?php include "menu.html"; ?></TD></TR>
           </table>
        </td>
	</tr>

	<tr>
		<td background="img/img_07.png" width="20" height="51"></td>
		<td background="img/img_08.png" width="762" height="51">DAFTAR ANGGOTA</td>
        <td background="img/img_09.png" width="18" height="51"></td>
	</tr>
	<tr>
		<td background="img/img_10.png" width="20" height="19"></td>
		<td background="img/img_11.png" width="762" height="19"></td>
		<td background="img/img_12.png" width="18" height="19"></td>
	</tr>
	<tr>
		<td background="img/img_13.png" width="20"></td>
		<td width="762" align="center">

	<form name="anggota" method="POST" action=""/>
            <table>
                <td>
                    <img src="img/korintus.jpg" align="left" height="120" >
                    
                </td>

            </table>
 <table width="628" border="0">


    </table>

<?php
  	   $jumtam = 10; $hal = $_POST[hal];
  	   if(empty($hal))
             { $startno=0; $hal=1; }
           else
             { $startno = ($hal-1) * $jumtam; };
        ?>

<table width="760" bgcolor="#999999">
    	<tr>
          <td width="100">&nbsp;&nbsp;&nbsp;Find</td>
          <td width="2">::::</td>
          <td colspan="528"><input type="text" name="txt_find" value="<?php echo "$_POST[txt_find]"; ?>" size="20" />&nbsp;&nbsp;
              <input type="submit" name="find" value="FIND"/>
          </td>
	</tr>
    </table>

     <table width="760" border="1" cellpadding="0" cellspacing="0">
		 <tr>
		   <td width="30" align="center">NO</td>
		   <td width="171" align="center">NO Anggota</td>
		   <td width="158" align="center">Nama Anggota</td>
		   <td width="191" align="center">Alamat</td>
            <td width="108" align="center">Telephon</td>
            <!--    <td width="225" align="center">Contact Person</td>   -->
		   <td width="88" align="center">View</td>
		<!--   <td width="98" align="center">Delete</td>   -->
		 </tr>
          <?php
           if($_POST['txt_find']!="")
	    { $sql="SELECT * FROM tb_anggota WHERE nm_anggota LIKE '%$_POST[txt_find]%' ORDER BY id"; }
	   else
	    { $sql="SELECT * FROM tb_anggota ORDER BY nm_anggota LIMIT $startno , $jumtam"; };
        	   $result=mysql_query($sql);
		   $clr="clear";
		   while($dt=mysql_fetch_array($result))
		   { $i++;
                   if($clr=='clear')
                   {
		 ?>

         <?php
  		if($clr=='clear')
  		{ echo "<tr bgcolor='#f0f9cd'>"; }
  		 else if($clr=='dark')
  		{ echo "<tr bgcolor='#bfc1b6'>"; }
  	?>
                 <tr>
           <td width="30" align="center"><?php echo "$i"; ?></td>
		   <td width="171" align="center"><?php echo "$dt[id]"; ?>&nbsp;</td>
		   <td width="158" align="center"><?php echo "$dt[nm_anggota]"; ?>&nbsp;</td>
		   <td width="191" align="center"><?php echo "$dt[alamat]"; ?>&nbsp;</td>
                   <td width="108" align="center"><?php echo "$dt[tlp]"; ?>&nbsp;</td>

<td width="88" align="center">
                       <a href="ms_anggota1.php?txt_anggotano=<?php echo "$dt[id]"?>&tipe=view">
                         <b><img src="img/home.png" alt="Big Boat" /></b>                       </a>            </td>
          </tr>
<?php
		   $clr = 'dark';
		   }
		   else if($clr=='dark')
  		   {
           ?>
                 <tr>
            <td width="30" align="center"><?php echo "$i"; ?></td>
		   <td width="171" align="center"><?php echo "$dt[id]"; ?>&nbsp;</td>
		   <td width="158" align="center"><?php echo "$dt[nm_anggota]"; ?>&nbsp;</td>
		   <td width="191" align="center"><?php echo "$dt[alamat]"; ?>&nbsp;</td>
                   <td width="108" align="center"><?php echo "$dt[tlp]"; ?>&nbsp;</td>

<td width="88" align="center">
                       <a href="ms_anggota1.php?txt_anggotano=<?php echo "$dt[id]"?>&tipe=view">
                         <b><img src="img/home.png" alt="Big Boat" /></b>                       </a>            </td>
          </tr>
<?php
			$clr = 'clear';
			}
			}
	    ?>


             <?php
		if($_POST['txt_find']!="")
		 {$sql2 = "SELECT * FROM tb_anggota WHERE nm_anggota LIKE '%$_POST[txt_find]%' ORDER BY id"; }
		    else
         { $sql2 = "SELECT * FROM tb_anggota ORDER BY id"; }
	    ?>

      <tr>
      <td colspan="8" align="center">
       <?php
				 $result2=mysql_query($sql2);
				 $jlhbaris=mysql_num_rows($result2);
				 $total_page=ceil($jlhbaris/$jumtam);
				 if(!empty($hal) && $hal !=1)
				 {
				 $previous=$hal-1;
				 echo "<A HREF=dt_anggota.php?hal=$previous><b>Previousssss</b></A> - ";
				 }
				 else
				 {echo "<b>Previoussssss -</b>";}
				 for($i=1;$i<=$total_page;$i++)
				 if ($i != $hal)
				 { echo"<a href=dt_anggota.php?hal=$i><b>$i</b></a> -";	}
				 else { echo "$i - "; }
				 if($hal < $total_page)
				 { $next=$hal+1; echo "<a href=dt_anggota.php?hal=$next><b>Next</b></a>"; }
				 else
				 { echo "<b>Next</b>"; }

				?>
	   </td>
	</table>

		<td background="img/img_15.png" width="18"></td>

	<tr>
	      <td background="img/img_16.png" width="20" height="34"></td>
	      <td background="img/img_17.png" width="762" height="34"></td>
              <td background="img/img_18.png" width="18" height="34"></td>
	</tr>
	<tr>
	  <td colspan="3" align="center">Copyright &#169; HKBP BONANG INDAH (2011)</td></tr>
</table>
<!-- End ImageReady Slices -->

<script type="text/javascript">
	var menuModel = new DHTMLSuite.menuModel();
	DHTMLSuite.configObj.setCssPath('css/');
	menuModel.addItemsFromMarkup('menuModel');
	menuModel.setMainMenuGroupWidth(00);
	menuModel.init();
	var menuBar = new DHTMLSuite.menuBar();
	menuBar.addMenuItems(menuModel);
	menuBar.setTarget('menuDiv');
	menuBar.init();
</script>

</body>
</center>
</html>
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Aug 28, 2014 · 0 Suka · 0 Tidak Suka
<?php
  include("include/connection.php");
 ?>
 
<html>
<head>
<title>HKBP BONANG APLIKASI</title>
<!-- css file included -->
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <link rel="stylesheet" href="css/calendar.css">
  <link rel="stylesheet" href="css/menu-item1.css" media="screen" type="text/css">
  <link rel="stylesheet" href="css/menu-bar1.css" media="screen" type="text/css">
  <link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />
  <link href="static_files/help.css" rel="stylesheet" type="text/css" media="all" />
<!-- css file included end -->
 
<!-- Java script funct -->
<script language="JavaScript" type="text/javascript">
    function hide(x) { document.getElementById(x).style.display='none'; }
    function show(x) { document.getElementById(x).style.display=''; }
    var GB_ROOT_DIR = "./greybox/";
 
</script>
<!-- Java script funct end-->
 
<!-- Java Script Included -->
  <script type="text/javascript" src="js/menu-for-applications.js"></script>
  <script type="text/javascript" src="greybox/AJS.js"></script>
  <script type="text/javascript" src="greybox/AJS_fx.js"></script>
  <script type="text/javascript" src="greybox/gb_scripts.js"></script>
  <script type="text/javascript" src="static_files/help.js"></script>
  <script language="JavaScript" src="js/calendar_us.js"></script>
<!-- Java Script Included end -->
 
 
 
</head>
<center>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (index.psd) -->
<table id="Table_01" width="800" border="0" cellpadding="0" cellspacing="0">
	<tr><td colspan="3">&nbsp;</td></tr>
	<tr>
		<td background="img/img_01.png" width="20" height="53">
		</td>
		<td background="img/img_02.png" width="762" height="53"><h2>HKBP BONANG APPLICATION
		</h2></td>
		<td background="img/img_03.png" width="18" height="53"></td>
	</tr>
	<tr>
        <td colspan="3" width="800">
           <table width="792.5" border="0" align="center" cellpadding="0" cellspacing="0">
             <TR><TD><?php include "menu.html"; ?></TD></TR>
           </table>
        </td>
	</tr>
 
	<tr>
		<td background="img/img_07.png" width="20" height="51"></td>
		<td background="img/img_08.png" width="762" height="51">DAFTAR ANGGOTA</td>
        <td background="img/img_09.png" width="18" height="51"></td>
	</tr>
	<tr>
		<td background="img/img_10.png" width="20" height="19"></td>
		<td background="img/img_11.png" width="762" height="19"></td>
		<td background="img/img_12.png" width="18" height="19"></td>
	</tr>
	<tr>
		<td background="img/img_13.png" width="20"></td>
		<td width="762" align="center">
 
	<form name="anggota" method="GET" action=""/> <!-- jangan pakai post untuk search -->
            <table>
                <td>
                    <img src="img/korintus.jpg" align="left" height="120" >
 
                </td>
 
            </table>
 <table width="628" border="0">
 
 
    </table>
 
<?php
  	   $jumtam = 10; $hal = $_GET['hal'];
  	   if(empty($hal))
             { $startno=0; $hal=1; }
           else
             { $startno = ($hal-1) * $jumtam; };
        ?>
 
<table width="760" bgcolor="#999999">
    	<tr>
          <td width="100">&nbsp;&nbsp;&nbsp;Find</td>
          <td width="2">::::</td>
          <td colspan="528"><input type="text" name="txt_find" value="<?php echo "$_GET[txt_find]"; ?>" size="20" />&nbsp;&nbsp;
              <input type="submit" name="find" value="FIND"/>
          </td>
	</tr>
    </table>
 
     <table width="760" border="1" cellpadding="0" cellspacing="0">
		 <tr>
		   <td width="30" align="center">NO</td>
		   <td width="171" align="center">NO Anggota</td>
		   <td width="158" align="center">Nama Anggota</td>
		   <td width="191" align="center">Alamat</td>
            <td width="108" align="center">Telephon</td>
            <!--    <td width="225" align="center">Contact Person</td>   -->
		   <td width="88" align="center">View</td>
		<!--   <td width="98" align="center">Delete</td>   -->
		 </tr>
          <?php
           if($_GET['txt_find']!="")
	    { $sql="SELECT * FROM tb_anggota WHERE nm_anggota LIKE '%$_GET[txt_find]%' ORDER BY id LIMIT $startno , $jumtam"; }
	   else
	    { $sql="SELECT * FROM tb_anggota ORDER BY nm_anggota LIMIT $startno , $jumtam"; };
        	   $result=mysql_query($sql);
		   $clr="clear";
		   while($dt=mysql_fetch_array($result))
		   { $i++;
                   if($clr=='clear')
                   {
		 ?>
 
         <?php
  		if($clr=='clear')
  		{ echo "<tr bgcolor='#f0f9cd'>"; }
  		 else if($clr=='dark')
  		{ echo "<tr bgcolor='#bfc1b6'>"; }
  	?>
                 <tr>
           <td width="30" align="center"><?php echo "$i"; ?></td>
		   <td width="171" align="center"><?php echo "$dt[id]"; ?>&nbsp;</td>
		   <td width="158" align="center"><?php echo "$dt[nm_anggota]"; ?>&nbsp;</td>
		   <td width="191" align="center"><?php echo "$dt[alamat]"; ?>&nbsp;</td>
                   <td width="108" align="center"><?php echo "$dt[tlp]"; ?>&nbsp;</td>
 
<td width="88" align="center">
                       <a href="ms_anggota1.php?txt_anggotano=<?php echo "$dt[id]"?>&tipe=view">
                         <b><img src="img/home.png" alt="Big Boat" /></b>                       </a>            </td>
          </tr>
<?php
		   $clr = 'dark';
		   }
		   else if($clr=='dark')
  		   {
           ?>
                 <tr>
            <td width="30" align="center"><?php echo "$i"; ?></td>
		   <td width="171" align="center"><?php echo "$dt[id]"; ?>&nbsp;</td>
		   <td width="158" align="center"><?php echo "$dt[nm_anggota]"; ?>&nbsp;</td>
		   <td width="191" align="center"><?php echo "$dt[alamat]"; ?>&nbsp;</td>
                   <td width="108" align="center"><?php echo "$dt[tlp]"; ?>&nbsp;</td>
 
<td width="88" align="center">
                       <a href="ms_anggota1.php?txt_anggotano=<?php echo "$dt[id]"?>&tipe=view">
                         <b><img src="img/home.png" alt="Big Boat" /></b>                       </a>            </td>
          </tr>
<?php
			$clr = 'clear';
			}
			}
	    ?>
 
 
             <?php
		if($_GET['txt_find']!="")
		 {$sql2 = "SELECT count(*) FROM tb_anggota WHERE nm_anggota LIKE '%$_GET[txt_find]%' ORDER BY id"; }
		    else
         { $sql2 = "SELECT count(*) FROM tb_anggota ORDER BY id"; }
	    ?>
 
      <tr>
      <td colspan="8" align="center">
       <?php
				 $result2=mysql_fetch_array(mysql_query($sql2));
				 $jlhbaris=$result2[0];
				 $total_page=ceil($jlhbaris/$jumtam);
				 if(!empty($hal) && $hal !=1)
				 {
				 $previous=$hal-1;
				 echo "<A HREF=dt_anggota.php?hal={$previous}&txt_find={$_GET['txt_find']}><b>Previousssss</b></A> - ";
				 }
				 else
				 {echo "<b>Previoussssss -</b>";}
				 for($i=1;$i<=$total_page;$i++)
				 if ($i != $hal)
				 { echo"<a href=dt_anggota.php?hal={$i}&txt_find={$_GET['txt_find']}><b>$i</b></a> -";	}
				 else { echo "$i - "; }
				 if($hal < $total_page)
				 { $next=$hal+1; echo "<a href=dt_anggota.php?hal={$next}&txt_find={$_GET['txt_find']}><b>Next</b></a>"; }
				 else
				 { echo "<b>Next</b>"; }
 
				?>
	   </td>
	</table>
 
		<td background="img/img_15.png" width="18"></td>
 
	<tr>
	      <td background="img/img_16.png" width="20" height="34"></td>
	      <td background="img/img_17.png" width="762" height="34"></td>
              <td background="img/img_18.png" width="18" height="34"></td>
	</tr>
	<tr>
	  <td colspan="3" align="center">Copyright &#169; HKBP BONANG INDAH (2011)</td></tr>
</table>
<!-- End ImageReady Slices -->
 
<script type="text/javascript">
	var menuModel = new DHTMLSuite.menuModel();
	DHTMLSuite.configObj.setCssPath('css/');
	menuModel.addItemsFromMarkup('menuModel');
	menuModel.setMainMenuGroupWidth(00);
	menuModel.init();
	var menuBar = new DHTMLSuite.menuBar();
	menuBar.addMenuItems(menuModel);
	menuBar.setTarget('menuDiv');
	menuBar.init();
</script>
 
</body>
</center>
</html>
0
Loading...
hendra · Sep 1, 2014 · 0 Suka · 0 Tidak Suka
Selamat pagi mas Ellyx,
Terimakasih untuk jawabannya, mantap.
Sukses selalu mas


salam