Advertisement
Guest User

Untitled

a guest
Jan 9th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="style2.css"/>
  4. </head>
  5. <body>
  6.  
  7. <?php include 'menu.php'; ?>
  8.  
  9. <form name="frmSearch" method="post" action="test2.php">
  10. <table border="0">
  11. <tr>
  12. <th>Artikel :
  13. <input name="var1" type="text" id="var1">
  14. <input type="submit" value="Search"></th>
  15. </tr>
  16. </table>
  17. </form>
  18.  
  19. <?php
  20. $nameofdb = 'db';
  21. $dbusername = 'root';
  22. $dbpassword = '';
  23.  
  24.  
  25. // Connect to MySQL via PDO
  26. try {
  27. $dbh = new PDO("mysql:dbname=$nameofdb;host=localhost", $dbusername, $dbpassword);
  28. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  29. } catch (PDOException $e) {
  30. echo 'Connection failed: ' . $e->getMessage();
  31. }
  32.  
  33. $var1 = str_replace(array('%','_'),'',$_POST['var1']);
  34. if (!$var1)
  35. {
  36. exit('Invalid form value: '.$var1);
  37. }
  38.  
  39.  
  40. $query = 'SELECT
  41. t1.`BSTKATNR`,
  42. t1.`BSTLIEFBST`,
  43. t1.`BSTLIEFTXT`,
  44. t1.`BSTARTBES1`,
  45. t1.`BSTANF`,
  46. t1.`BSTSTLIO`,
  47. t1.`BSTLIEFMIN`,
  48. t1.`BSTMIND`,
  49. t1.`BSTARTMASS`,
  50. t1.`BSTKUMST`,
  51. t1.`BSTKUMVK`,
  52. t1.`BSTKUMER`
  53. FROM `elebest` AS t1 WHERE
  54. ( t1.`BSTLIEFBST` LIKE :search ) OR
  55. ( t1.`BSTKATNR` LIKE :search ) OR
  56. ( t1.`BSTLIEFTXT` LIKE :search ) OR
  57. ( t1.`BSTARTBES1` LIKE :search)';
  58.  
  59.  
  60. $stmt = $dbh->prepare($query);
  61. $stmt->bindValue(':search', '%' . $var1 . '%', PDO::PARAM_INT);
  62. $stmt->execute();
  63.  
  64. /* Fetch all of the remaining rows in the result set */
  65. print(" ");
  66.  
  67.  
  68. $result = $stmt->fetchAll();
  69.  
  70. foreach( $result as $row ) {
  71.  
  72. echo "<div id='uberschrift'>" ;
  73. echo 'Artikelnummer : ' ;
  74. echo $row["BSTKATNR"];
  75. echo '<br>' ;
  76. echo 'LF. Nr. : ' ;
  77. echo $row["BSTLIEFBST"];
  78. echo '<br>' ;
  79. echo '<br>' ;
  80. echo 'Beschreibung : ' ;
  81. echo $row["BSTARTBES1"];
  82. echo "</div>" ;
  83.  
  84. echo "<div id='links'>" ;
  85. echo '<br>' ;
  86. echo 'Bestand : ' ;
  87. echo $row["BSTANF"];
  88. echo '<br>' ;
  89. echo 'Verf&uuml;gbar : ' ;
  90. echo $row["BSTSTLIO"];
  91. echo '<br>' ;
  92. echo '<br>' ;
  93. echo 'Verkaufszahlen Aktuelles Jahr : ' ;
  94. echo '<br>' ;
  95. echo '<br>' ;
  96. echo 'St&uuml;ck : ' ;
  97. echo $row["BSTKUMST"];
  98. echo '<br>' ;
  99. echo 'Umsatz : ' ;
  100. echo $row["BSTKUMVK"]; echo ' &euro;' ;
  101. echo '<br>' ;
  102. echo 'Ertrag : ' ;
  103. echo $row["BSTKUMER"]; echo ' &euro;' ;
  104. echo '<br>' ;
  105. echo '<br>' ;
  106. echo "</div>" ;
  107. }
  108.  
  109. ?>
  110.  
  111. </body>
  112. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement