Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 2.91 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. data from dropdown box in form being sent to db as 'Array'
  2. <?php
  3. include ('../connect.php');
  4.  
  5. if(isset($_POST['submit']))
  6. {
  7.  
  8. $qty = $_POST['qty'];
  9. $mob_name = $_POST['mob_name'];
  10. $item_img = $_POST['item_img'];
  11. $item_name = $_POST['item_name'];
  12.  
  13.  
  14. //save the name of image in table
  15. $query = mysql_query("INSERT INTO tbl_drop VALUES('','$mob_name','$item_img','$item_name','$qty')") or die(mysql_error());
  16.  
  17.  
  18. }
  19.  
  20. $query_Recordset1 = "SELECT mob_name FROM tbl_img ORDER BY mob_name ASC";
  21. $Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
  22. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  23. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  24.  
  25. $query_Recordset2 = "SELECT item_name FROM tbl_itm ORDER BY item_name ASC";
  26. $Recordset2 = mysql_query($query_Recordset2) or die(mysql_error());
  27. $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  28. $totalRows_Recordset2 = mysql_num_rows($Recordset2);
  29.  
  30. $query_Recordset3 = "SELECT item_img FROM tbl_itm ORDER BY item_name ASC";
  31. $Recordset3 = mysql_query($query_Recordset3) or die(mysql_error());
  32. $row_Recordset3 = mysql_fetch_assoc($Recordset3);
  33. $totalRows_Recordset3 = mysql_num_rows($Recordset3);
  34.  
  35. ?>
  36.  
  37. <html>
  38. <head>
  39. <title></title>
  40. </head>
  41.  
  42. <body>
  43. <form id="form1" name="form1" enctype="multipart/form-data" method="post" action="new_drop.php">
  44. <label>Mob Name:
  45. <select name="mob_name" id="mob_name">
  46. <?php
  47. do {
  48. ?>
  49. <option value="<?php echo $row_Recordset1?>"><?php echo $row_Recordset1['mob_name']?></option>
  50. <?php
  51. } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  52. $rows = mysql_num_rows($Recordset1);
  53. if($rows > 0) {
  54. mysql_data_seek($Recordset1, 0);
  55. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  56. }
  57. ?>
  58. </select>
  59. </label>
  60. <p>
  61. <label>Item Name:
  62. <select name="item_name" id="item_name">
  63. <?php
  64. do {
  65. ?>
  66. <option value="<?php echo $row_Recordset2?>"><?php echo $row_Recordset2['item_name']?></option>
  67. <?php
  68. } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
  69. $rows = mysql_num_rows($Recordset2);
  70. if($rows > 0) {
  71. mysql_data_seek($Recordset2, 0);
  72. $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  73. }
  74. ?>
  75. </select>
  76. </label>
  77. <p>
  78. <label>Item Image:
  79. <select name="item_img" id="item_img">
  80. <?php
  81. do {
  82. ?>
  83. <option value="<?php echo $row_Recordset3?>"><?php echo $row_Recordset3['item_img']?></option>
  84. <?php
  85. } while ($row_Recordset3 = mysql_fetch_assoc($Recordset3));
  86. $rows = mysql_num_rows($Recordset3);
  87. if($rows > 0) {
  88. mysql_data_seek($Recordset3, 0);
  89. $row_Recordset3 = mysql_fetch_assoc($Recordset3);
  90. }
  91. ?>
  92. </select>
  93. </label>
  94. <p>
  95. <label>Quantity:
  96. <input type='text' name='qty' />
  97. </label>
  98. <p>
  99. <label>
  100. <input type="submit" name="submit" id="submit" value="Submit" />
  101. </label>
  102. </p>
  103. </form>
  104. </body>
  105. </html>
  106. <?php
  107. mysql_free_result($Recordset1);
  108. mysql_free_result($Recordset2);
  109. mysql_free_result($Recordset3);
  110. ?>
  111.        
  112. <option value="<?php echo $row_Recordset3?>"><?php echo $row_Recordset3['item_img']?></option>
  113.        
  114. <option value="<?php echo $row_Recordset3['item_img']?>"><?php echo $row_Recordset3['item_img']?></option>