Advertisement
Guest User

Untitled

a guest
Mar 18th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <?php
  2.  
  3. $DB_host = "localhost";
  4. $DB_user = "root";
  5. $DB_pass = "";
  6. $DB_name = "test_shop";
  7. $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf-8');
  8. try
  9. {
  10. $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
  11. $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12. $DB_con->exec('SET NAMES utf8');
  13. }
  14. catch(PDOException $e)
  15. {
  16. $e->getMessage();
  17. }
  18. ?>
  19.  
  20. <style>
  21. .left{
  22.  
  23.  
  24. }
  25. .new{
  26.  
  27. display: inline-block;
  28.  
  29. }
  30. .add{
  31.  
  32. display: inline-block;
  33. }
  34. .woname_cat{
  35. display: inline-block;
  36. }
  37. </style>
  38.  
  39. <div class="left">
  40. <?php
  41. $stmt = $DB_con->query("SELECT * FROM `test_table`");
  42. while ($row = $stmt->fetch())
  43. {
  44.  
  45. echo
  46. '
  47.  
  48. <form method="POST" class="new">
  49. <input type="hidden" name="con" value="'.$row['number'].'"/>
  50. <input type="submit" name="selecteds" value="'.$row['name'].'"/>
  51. </form>
  52.  
  53. ';
  54. }
  55.  
  56.  
  57. ?>
  58. </div>
  59.  
  60. <div class="add">
  61. <?php
  62. if(isset($_POST['selecteds'])){
  63. $id = $_POST['con'];
  64. $stmt = $DB_con->query("SELECT * FROM `cat_woman` WHERE `number` ='$id' ");
  65. while ($row = $stmt->fetch())
  66. {
  67. echo '
  68.  
  69. <form method="POST" class="woname_cat">
  70. <input type="hidden" name="cat_shop" value="'.$row['number'].'"/>
  71. <input type="submit" name="shopw" value="'.$row['shop'].'"/>
  72. </form>
  73.  
  74. ';
  75. }
  76. }
  77. ?>
  78. </div>
  79. <div>
  80. <?php
  81. if(isset($_POST['shopw'])){
  82. $id = $_POST['cat_shop'];
  83. $stmt = $DB_con->query("SELECT * FROM `product` WHERE `id_cat` ='$id' ");
  84. while ($row = $stmt->fetch())
  85. {
  86. echo '
  87.  
  88. <p>'.$row['name'].'</p>
  89. <p>'.$row['desc'].'</p>
  90.  
  91. ';
  92. }
  93. }
  94. ?>
  95.  
  96. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement