Showing posts with label multiple form. Show all posts
Showing posts with label multiple form. Show all posts

Wednesday, December 9, 2009

Place multiple submit form on page

Fetch all record form image table and create form as per record on a single page. and submit form on button. With the following example code u can place multiple submit form on single page and submit single form according to button submit. display form with pagination.
 This example will help in understand pagination in php.


<!--
  Javascript Function for submit Form

  -->

  <script language="javascript">


  function function1(theForm){

  theForm.submit();

  }
  </script>


<?php



$dbc=mysql_connect('hostname','username','password');
  mysql_select_db('databasename',$dbc);

  $start=$_REQUEST['startPostion'];
  $display=20;

  if(isset($start)&&is_numeric($start)){
  $startNo=trim($start);
  }else{
  $startNo=0;
  }

  /*

  Get TotalNo of Images in images table for calculate the no of pages

  */


  $selCount="select count(id) from images where status='Ok'";
  $countRs=mysql_query($selCount,$dbc);

  $count=mysql_fetch_row($countRs);

  if($count[0]>$display){

  $pages=ceil($count[0]/$display);

  }else{

  $pages=1;
  }





if($pages>1){
  $currentPage=($startNo/$display)+1;

  $stPageNo=$currentPage-4;
  $endPageNo=(($currentPage+5)<$pages)? $currentPage+5 : $pages;
  if($currentPage!=1){
  echo '<a href="imageManager.php?startPostion='.($startNo-$display).'"><span class="nextpre">Previous&nbsp;</span></a>';
  }

  for($i=$stPageNo;$i<=$endPageNo;$i++){
  if($i>0){
  if($i==$currentPage){

  echo '<span class="currpagingNo">'.$i.' '.'</span>';
  }else{
  echo '<a href="imageManager.php?startPostion='.($display*($i-1)).'"><span class="pagingNo">'.$i.' '.'</span></a>';
  }
  }



  } echo '<span class="nextpre">...of '.$pages.'</span>';
  if($currentPage!=$pages){
  echo '<a href="wallpaperManager.php?startPostion='.($startNo+$display).'"><span class="nextpre">Next</span></a>';
  }
  }
  ?>

  <table border="1" cellspacing="0" cellpadding="0">
  <tr>
  <td width="360" align="center"><span class="style1">Wallpaper Detail </span> </td>
  <td width="72" align="center"><span class="style1">Added Date</span> </td>
  <td align="center"><span class="style1">Action </span></td>
  </tr>
  <?php
  $selImage="select * from images where status='Ok' limit $startNo,$display";
  $imageResult=mysql_query($selImage,$dbc);

  while($row=mysql_fetch_row($imageResult)){
  ?>
  <tr>
  <td height="150" valign="top" >
  <table width="340" border="1" cellspacing="0" cellpadding="0">
  <form id="form1" name="forms<?php echo $row[0]; ?>" method="post" action="imageManager.php">
  <tr>
  <td width="80"> <span class="style1">Title</span> </td>
  <td width="254">
  <input type="text" name="photo_title" size="50" value="<?php echo $row[1]; ?>">  <input type="hidden" name="ask" value="activate" >
  </td>
  </tr>
  <tr>
  <td width="80"> <span class="style1">Description</span> </td>
  <td width="254">
  <input type="text" name="photo_desi" size="50" value="<?php echo $row[2]; ?>">  <input type="hidden" name="ask" value="activate" >
  </td>
  </tr>

  </form>
  </table>

  </td>

  <td align="center"><span id="textstyle"><?php  echo $row[3]; ?></span></td>
  <td align="center" width="38" valign="middle"><img src="../../All Users/Documents/images/yes.png" border="0" title="Activate" onclick="function1(forms<?php echo $row[0]; ?>)"></a></td>

  </tr>

  <?php
  }
  ?>
  </table>