Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <?php
  2.  
  3. **if(isset($_GET['Product']) && !empty($_GET['Product'])){
  4.  
  5. include('conexao.php');
  6.  
  7. $id = $_GET['Product'];
  8.  
  9. $query = "SELECT Unidades.Description FROM dbcentro.Produtos RIGHT JOIN dbcentro.Unidades ON Unidades.IDUnid = Produtos.IDDesc WHERE Produtos.ID='$id'";
  10. $do = mysqli_query($conn, $query);
  11. $count = mysqli_num_rows($do);**
  12.  
  13. if (count > 0){
  14. while($row=mysqli_fetch_array($do)){
  15.  
  16. echo '<option value="'.$row['ID'].'">'.$row['Description'].'</option>';
  17. }
  18.  
  19.  
  20. }else{
  21. echo '<option>Not Unit Availble</option>';
  22. }
  23.  
  24. }**else{
  25. echo '<h1>Error</h1>';
  26. }**
  27. ?>
  28.  
  29. <html>
  30.  
  31. <?php
  32. $servername = "xxxxxxxxx";
  33. $username = "xxxxxx";
  34. $password = "xxxxxx";
  35. $dbname = "xxxxxx";
  36. $conn = mysqli_connect($servername, $username, $password, $dbname) or
  37. die(mysqli_connect_error());
  38.  
  39. ?>
  40. </html>
  41.  
  42. <title>FORMULÁRIO </title>
  43.  
  44. <link rel="stylesheet" src="Bootstrap/js/bootstrap.min.js">
  45. <script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
  46.  
  47. **<script>
  48. $(document).ready(function(){
  49. $('#Product').on('change',function(){
  50. var ProductID= $(this).val();
  51. if(ProductID){
  52. $.get(
  53. "ajax.php",
  54. {Product: ProductID},
  55. function(data){
  56. $('#Unit').html(data);
  57. }
  58.  
  59. );
  60. }else{
  61. $('#Unit').html('<option>Primeiro Selecione Produto</option>')
  62.  
  63. }
  64.  
  65. });
  66. });
  67. </script**
  68. <body>
  69.  
  70. <div class="conteudoConvenio">
  71. <div style="width: 25% !important;background: #87cefa; text-align:center;">
  72. <fieldset>
  73.  
  74. <legend>Formulário</legend
  75. <form class="text-center" action="conexao.php" method="POST">
  76. <div class="form-group">
  77.  
  78. **<b>Produtos:</b>
  79. <br>
  80. <select class="form-control" id="Product">
  81. <option>Selecione Produto</option>
  82. <?php
  83. $result_Produtos = "SELECT * FROM Produtos";
  84. $resultado_Produtos = mysqli_query($conn, $result_Produtos);
  85. while($row_Produtos = mysqli_fetch_array($resultado_Produtos)){ ?>
  86. <option value="<?php echo $row_Produtos['ID']; ?>"><?php echo
  87. $row_Produtos['Product']; ?>
  88. </option> <?php
  89. }
  90. ?>
  91. </select><br>
  92. <b>Unidade:</b>
  93. <br>
  94. <select class="form-control" id="unit">
  95. <option>Primeiro Selecione Produto</option>
  96. </select><br>**
  97. </div>
  98.  
  99. </select><br>
  100. <br>
  101. <input type="submit" name="adicionar" value="Adicionar">
  102. </form>
  103. </fieldset>
  104. </div>
  105.  
  106. </body>
  107. </html>
  108.  
  109. $count = mysqli_num_rows($do);
  110.  
  111. if (count > 0) {...
  112.  
  113. $count = mysqli_num_rows($do);
  114.  
  115. if ($count > 0) {...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement