daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Jun 5th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php  
  2. session_start();
  3. echo "<strong>Update multiple rows in mysql</strong><br>";
  4. $host="localhost"; // Host name
  5. $username=$_SESSION['myusername']; // Mysql username
  6. $password=$_SESSION['mypassword'];
  7. $db_name="teams"; // Database name
  8. $tbl_name=$_GET['team'];// Table name
  9.  
  10.  
  11. // Connect to server and select databse.
  12. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  13. mysql_select_db("$db_name")or die("cannot select DB");
  14.  
  15. $sql="SELECT * FROM $tbl_name";
  16. $result=mysql_query($sql);
  17. $sql2="SELECT * FROM site ORDER BY PLACE";
  18. $wynik=mysql_query($sql2);
  19. //$place = mysql_query("SELECT PLACE FROM site, $tbl_name WHERE 'ID'='FK_PLACE'") or die ('blad');
  20. //$num=mysql_query($place);
  21.  
  22. // Count table rows
  23. $count=mysql_num_rows($result);
  24. function kurwa($j, $b ) {
  25. echo $j;
  26. echo $b;
  27. $sql2="SELECT * FROM site ORDER BY PLACE";
  28. $wynik=mysql_query($sql2);
  29. ?>
  30. <select name="site[<?php echo $j?>]"><option selected="selected">Pick a Site</option><?php  
  31.     while($sit = mysql_fetch_array($wynik))
  32.         {
  33.         $site_name=$sit['PLACE'];?>
  34.  
  35.             <option name='place' value="<?php echo $sit["ID"]?>" ><?php echo $site_name;?></option>
  36.         <?php
  37.         }
  38.         return $site[$j];
  39.         }
  40.         ?>
  41.        
  42. <table align="center" width="500" border="1" cellspacing="1" cellpadding="0" bgcolor="#800080">
  43. <form name="form1" method="get" action="update_ac_mem.php">
  44. <tr>
  45. <td>
  46. <table align="center" width="500" border="0" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF">
  47.  
  48.  
  49. <tr>
  50. <td align="center"><strong>Id</strong></td>
  51. <td align="center"><strong>Member</strong></td>
  52. <td align="center"><strong>Phone</strong></td>
  53. <td align="center"><strong>Site</strong></td>
  54. <td align="center"><strong><font color="red">Delete</font></strong></td>
  55.  
  56.  
  57.  
  58. </tr>
  59. <?php
  60. $j=0;
  61. while($rows=mysql_fetch_array($result)){
  62. ?>
  63. <tr>
  64. <td align="center"><?php echo $rows['ID']; ?></td>
  65. <td align="center"><input name="memb[<?php echo $j?>]" type="text" id="memb" value="<?php echo $rows['MEMBER']; ?>"></td>
  66. <td align="center"><input name="phone[<?php echo $j?>]" type="text" id="phone" value="<?php echo $rows['PHONE']; ?>"></td>
  67. <td align="center"><?php kurwa($j, $rows['FK_SITE'])?>
  68.                 </td>
  69. <td align="center"><input name="checkbox[<?php echo $j?>]" type="checkbox" id="checkbox" value="<?php echo $rows['ID']; ?>"></td>
  70. <td align="center"><input name="count" type="hidden" id="count" value="<?php echo $count ?>" ></td>
  71. <td align="center"><input name="table" type="hidden" id="table" value="<?php echo $tbl_name ?>" ></td>
  72. <td align="center"><input name="id[<?php echo $j?>]" type="hidden" id="id" value="<?php echo $rows['ID']; ?>" ></td>
  73.  
  74.  
  75.  
  76. </tr>
  77. <?php
  78. $j++;
  79. }?>
  80.  
  81. <tr>
  82. <td colspan="8" align="center"><input type="submit" name="Submit" value="Submit"></td>
  83. </tr>
  84. </table>
  85. </td>
  86. </tr>
  87. </form>
  88. </table>
  89. <center><a href="list_records.php">Update and Delete Team names</a><br></center>
  90.  
  91. <?php
  92. // Check if button name "Submit" is active, do this
  93. mysql_close();
  94. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top