Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]TABLICE
mattii
post
Post #1





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 29.01.2010

Ostrzeżenie: (0%)
-----



mam problem z tablicami....

mam formularz z opcją wyboru, który wyrzuca mi dostępne nazwiska uczniów - działa dobrze.

tylko problem mam jak chciałbym aby po naciśnięciu przycisku uzyskac id wybranego ucznia... próbuje na różne sposoby...m.in tak jak poniżej, ale nic mi nie działa.. gdzie robię błąd ?


  1.  
  2.  
  3. if(isset($_POST['btn-'])) {
  4.  
  5.  
  6.  
  7. $idzaw = strip_tags($_POST['idzaw'][$i]);
  8. $idzaw = $DBcon->real_escape_string($idzaw);
  9.  
  10. echo "id zawodnika to:", $idzaw;
  11.  
  12.  
  13.  
  14. }
  15.  
  16.  
  17. }
  18.  
  19.  
  20.  
  21. .
  22. .
  23. .
  24. .
  25.  
  26.  
  27. <form autocomplete="off" method="post" >
  28.  
  29. <select class="form-control" name="idzaw[]" >
  30.  
  31. <?php
  32.  
  33.  
  34. $Zquery = $DBcon->query("SELECT * FROM ... ");
  35.  
  36. $ileZ=$Zquery->num_rows;
  37.  
  38. for ($i=0; $i <$ileZ; $i++)
  39. {
  40.  
  41.  
  42. $dzieckoRowF=$Zquery->fetch_array();
  43.  
  44. ?>
  45. <option value="<?$dzieckoRowF['idzawodnik']?>">
  46.  
  47.  
  48.  
  49. <?php echo $i+1 , '. ', $dzieckoRowF['idzawodnik'] , $dzieckoRowF['imie'] , ' ', $dzieckoRowF['nazwisko']; ?> </option>
  50.  
  51.  
  52. <?
  53.  
  54. }
  55.  
  56. ?>
  57.  
  58.  
  59. </select>
  60. </div>
  61.  
  62. <div class="form-group">
  63. <button class="btn btn-block btn-primary" name="btn" type="submit">potwierdź</button>
  64. </div>
  65.  
  66.  
  67. </form>
  68.  
  69.  
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
mattii
post
Post #2





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 29.01.2010

Ostrzeżenie: (0%)
-----


  1.  
  2.  
  3. array (
  4. 'idzaw' =>
  5. array (
  6. 0 => '',
  7. 'btn-FMS' => '',
  8. )
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  26. <html xmlns="http://www.w3.org/1999/xhtml">
  27. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  28. <title>Witaj mat</title>
  29.  
  30.  
  31.  
  32.  
  33.  
  34. <link href="css/main.css" rel="stylesheet">
  35. <link href="css/bootstrap.min.css" rel="stylesheet">
  36.  
  37.  
  38. <link rel="stylesheet" href="style.css" type="text/css" />
  39. <link href="css/font-awesome.min.css" rel="stylesheet">
  40.  
  41. <link rel="stylesheet" type="text/css" href="./jquery.datetimepicker.css"/>
  42.  
  43.  
  44. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>
  45. <script type="text/javascript">
  46. function loadPage(file) {
  47. $('#laduj').load(file);
  48. }
  49. </script>
  50.  
  51.  
  52.  
  53.  
  54.  
  55. </head>
  56.  
  57.  
  58.  
  59. <header id="header">
  60. <nav id="main-menu" class="navbar navbar-default navbar-fixed-top" role="banner">
  61. <div class="container">
  62. <div class="navbar-header">
  63. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
  64. <span class="sr-only">Profil l</span>
  65. <span class="icon-bar"></span>
  66. <span class="icon-bar"></span>
  67. <span class="icon-bar"></span>
  68. </button>
  69. <a class="navbar-brand" href="../index.html"><img src="images/logo.png" alt="logo"></a>
  70. </div>
  71.  
  72. <div id="navbar" class="navbar-collapse collapse">
  73.  
  74. <ul class="nav navbar-nav">
  75.  
  76. <li ><a href="home.php"><span class="fa fa-male "></span>&nbsp;Dane </a></li> <!--/.class="active" -->
  77.  
  78. <li>
  79. <a href="#" onClick="loadPage('dziecko.php');"><span class="fa fa-child"></span>&nbsp;Dane 2</a></li>
  80.  
  81.  
  82. </ul>
  83.  
  84.  
  85. <ul class="nav navbar-nav navbar-right">
  86. <li><a href="index.php"><span class="glyphicon glyphicon-user"></span>&nbsp; mat</a></li>
  87. <li><a href="logout.php?logout"><span class="glyphicon glyphicon-log-out"></span>&nbsp; Wyloguj</a></li>
  88. </ul>
  89. </div>
  90. </div><!--/.container-->
  91. </nav><!--/nav-->
  92. </header><!--/header-->
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. <section id="cta2">
  100.  
  101. <section id="meet-team">
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. <div class="container">
  117.  
  118.  
  119.  
  120. <div id="laduj">
  121. <div class="row">
  122. <div class="col-sm-2 col-md-6">
  123.  
  124. <div class="team-member wow fadeInUp" data-wow-duration="400ms" data-wow-delay="0ms">
  125.  
  126. <div class="team-info">
  127.  
  128. <div class="team-img">
  129. <h3>Nazwa: ni</h3>
  130. </div>
  131.  
  132.  
  133.  
  134. <p>Rocznik: 20
  135.  
  136.  
  137. </div>
  138. <p><br>
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. <form autocomplete="off" method="post" >
  158.  
  159.  
  160.  
  161. <div class="form-group">
  162. <h2 class="">Uzupełnij dane </h2>
  163.  
  164. 11</div>
  165. <div class="form-group">
  166. <hr>
  167. </div>
  168.  
  169.  
  170.  
  171.  
  172. <div class="form-group">
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. <div class="form-group">
  186. <label for="sel1">Wybierz :</label>
  187. <select class="form-control" name="idzaw[]" >
  188.  
  189.  
  190. <option value="1">
  191.  
  192.  
  193.  
  194. 1. 1a
  195.  
  196.  
  197. </option>
  198.  
  199.  
  200.  
  201. <option value="2">
  202.  
  203.  
  204.  
  205. 2. 2m
  206.  
  207.  
  208. </option>
  209.  
  210.  
  211.  
  212. <option value="3">
  213.  
  214.  
  215.  
  216. 3. 3a a
  217.  
  218.  
  219. </option>
  220.  
  221.  
  222.  
  223. <option value="4">
  224.  
  225.  
  226.  
  227. 4. 4w w
  228.  
  229.  
  230. </option>
  231.  
  232.  
  233.  
  234. <option value="5">
  235.  
  236.  
  237.  
  238. 5. 5qq qq
  239.  
  240.  
  241. </option>
  242.  
  243.  
  244.  
  245. <option value="6">
  246.  
  247.  
  248.  
  249. 6. 6fff fff
  250.  
  251.  
  252. </option>
  253.  
  254.  
  255.  
  256. <option value="7">
  257.  
  258.  
  259.  
  260. 7. 7bmm mm
  261.  
  262.  
  263. </option>
  264.  
  265.  
  266.  
  267. <option value="8">
  268.  
  269.  
  270.  
  271. 8. 8uu uu
  272.  
  273.  
  274. </option>
  275.  
  276.  
  277.  
  278.  
  279. </select>
  280. </div>
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302. <div class="form-group">
  303. <hr>
  304. </div>
  305. <div class="form-group">
  306. <button class="btn btn-block btn-primary" name="btn" type="submit">Dodaj</button>
  307. </div>
  308. <div class="form-group">
  309.  
  310. </div>
  311. </form>
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352. </div>
  353.  
  354. </div></div></div> </form>
  355. </div>
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382. </section>
  383. </section>
  384.  
  385.  
  386. <footer id="footer">
  387. <div class="container">
  388. <div class="row">
  389. <div class="col-sm-6">
  390. &copy; 2017
  391. </div>
  392. <div class="col-sm-6">
  393. <ul class="social-icons">
  394. <li><a href="#"><i class="fa fa-facebook"></i></a></li>
  395.  
  396. <li><a href="#"><i class="fa fa-youtube"></i></a></li>
  397.  
  398. </ul>
  399. </div>
  400. </div>
  401. </div>
  402. </footer><!--/#footer-->
  403.  
  404. <script src="js/jquery.js"></script>
  405. <script src="js/bootstrap.min.js"></script>
  406.  
  407. <script src="js/main.js"></script>
  408.  
  409. <script src="build/jquery.datetimepicker.full.js"></script>
  410. <script>/*
  411. window.onerror = function(errorMsg) {
  412. $('#console').html($('#console').html()+'<br>'+errorMsg)
  413. }*/
  414.  
  415. $.datetimepicker.setLocale('pl');
  416.  
  417. $('#datetimepicker_format').datetimepicker({value:'2015/04/15 05:03', format: $("#datetimepicker_format_value").val()});
  418. console.log($('#datetimepicker_format').datetimepicker('getValue'));
  419.  
  420. $("#datetimepicker_format_change").on("click", function(e){
  421. $("#datetimepicker_format").data('xdsoft_datetimepicker').setOptions({format: $("#datetimepicker_format_value").val()});
  422. });
  423. $("#datetimepicker_format_locale").on("change", function(e){
  424. $.datetimepicker.setLocale($(e.currentTarget).val());
  425. });
  426.  
  427.  
  428. $('#datetimepicker').datetimepicker({value:'2015/04/15 05:03',step:10});
  429.  
  430. $('.some_class').datetimepicker();
  431.  
  432.  
  433.  
  434.  
  435.  
  436. $('#datetimepicker2').datetimepicker({
  437. yearOffset:0,
  438. lang:'pl',
  439. timepicker:false,
  440. format:'Y/m/d',
  441. formatDate:'Y/m/d',
  442. minDate:'+1960/01/02', // yesterday is minimum date
  443. maxDate:'+1970/01/02' // and tommorow is maximum date calendar
  444. });
  445.  
  446.  
  447.  
  448.  
  449. </body>
  450. </html>
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  












coś drgnęło chyba, bo jak wybiorę id 8 to mam:

  1. array ( 'idzaw' => array ( 0 => '8', ),



a jak np id 5 to:

  1. array ( 'idzaw' => array ( 0 => '5', ),




znaczy pewnie jak chce potem to wyświetlić to jest coś nie tak ?

  1. $idzaw = strip_tags($_POST['idzaw'][$i]);
  2. $idzaw = $DBcon->real_escape_string($idzaw);
  3.  
  4.  
  5.  
  6. echo "id to:", $idzaw,"i to:", $i, var_export($_POST);


Ten post edytował mattii 22.11.2017, 10:22:46
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.10.2025 - 08:08