Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Wyświetlanie daty z bazy danych w divie
Forum PHP.pl > Forum > Przedszkole
slawekxx
Witam , chciałbym umieścić kod php w div-ie . Kod ,który wyświetla datę pobraną z archiwum baza mysql coś np w stylu <?php print(date('Y')); ?>
nospor
i czego nie wiesz? Jak umiescic w divie czy pobrac z bazy?

ps: przenosze
slawekxx
jak pobrać z bazy i napisać kod choć część kodu mam
  1. if ($_POST)
  2. {
  3. if (!empty($_POST['region']) && is_scalar($_POST['region']))
  4. {
  5. $region = mysql_real_escape_string($_POST['region']);
  6.  
  7. $resource = mysql_query('SELECT `name_pl`,`region`,`dzien`,`czas`,`wind_dir`,`wind_force`,`temperature`,`pressur
    e`,`lat`,`lng` FROM region
  8.  
  9. , pogoda WHERE region= "'.$region.'" AND region.station_id=pogoda.station_id ') or die(mysql_error());
  10.  
  11. while($rew=mysql_fetch_array($resource)){
  12.  
  13. echo "<table>";
  14. echo"<tr>";
  15. echo "<h4><th>" .$rew['name_pl'] ."</th></h4>";
  16. echo "<h4><th>" .$rew['region.station_id']."</th></h4>";
  17. echo "<h4><th>" .$rew['region']."</th></h4>";
  18. echo "<h4><th>" .$rew['dzien']."</th></h4>";
  19. echo "<h4><th>" .$rew['czas']."</th></h4>";
  20. echo "<h4><th>" .$rew['wind_dir']."</th></h4>";
  21. echo "<h4><th>" .$rew['wind_force']."</th></h4>";
  22. echo "<h4><th>" .$rew['temperature']."</th></h4>";
  23. echo "<h4><th>" .$rew['pressure']."</th></h4>";
  24. echo "<h4><th>" .$rew['lat']."</th></h4>";
  25. echo "<h4><th>" .$rew['lng']."</th></h4>";
  26. echo "</tr>";
  27. echo "</table>";
Otto
Troche nie rozumiem twojego pytania... Nie wiesz jak umieszczac kod w divie ale z tego co wiedze umiesz umieszczac kod w znacznikach <h4> bądz <th> a przez to i to, to html...
nospor
Cytat
choć część kodu mam
czyli masz wszystko. W czym więc problem?
slawekxx
W tym, że nie wyświetla się data i czas w divie
nospor
Kod co podałeś nie zawiera diva wiec trudno by się w divie coś wyświetlało smile.gif
slawekxx
To jest ten kod
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  5. <title></title>
  6. <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.4.custom.css" rel="stylesheet" />
  7. <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
  8. <script type="text/javascript" src="js/jquery-ui-1.8.4.custom.min.js"></script>
  9. <script type="text/javascript">
  10. $(function(){
  11.  
  12. // Accordion
  13. $("#accordion").accordion({ header: "h3" });
  14.  
  15. // Tabs
  16. $('#tabs').tabs();
  17.  
  18.  
  19. // Dialog
  20. $('#dialog').dialog({
  21. width: 900,
  22. height: 800,
  23. modal: true,
  24. buttons: {
  25. "Ok": function() {
  26. $(this).dialog("close");
  27. },
  28. "Cancel": function() {
  29. $(this).dialog("close");
  30. }
  31. }
  32. });
  33.  
  34. // Dialog Link
  35. $('#dialog_link').click(function(){
  36. $('#dialog').dialog('open');
  37. return false;
  38. });
  39.  
  40.  
  41.  
  42. //hover states on the static widgets
  43. $('#dialog_link, ul#icons li').hover(
  44. function() { $(this).addClass('ui-state-hover'); },
  45. function() { $(this).removeClass('ui-state-hover'); }
  46. );
  47.  
  48. });
  49. </script>
  50. <style type="text/css">
  51. /*demo page css*/
  52. body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;}
  53. .demoHeaders { margin-top: 2em; }
  54. #dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
  55. #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
  56. ul#icons {margin: 0; padding: 0;}
  57. ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left; list-style: none;}
  58. ul#icons span.ui-icon {float: left; margin: 0 4px;}
  59. th{text-align:center;}
  60. </style>
  61.  
  62.  
  63.  
  64.  
  65. </head>
  66. <body>
  67.  
  68. <p><a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Mapa pogody</a></p>
  69. <div id="dialog" title="Mapa Pogody na dzień<?php [b]TUTAJ CHCĘ WYŚWIETLIĆ DATĘ , KTÓRA ZOSTAŁA WYBRANA Z BAZY[/b] ?>
  70. ">
  71.  
  72.  
  73.  
  74. <form name="form1" id="form1" action="" method="post">
  75. <table>
  76.  
  77. <tr><td><b>Wybierz Region</b></td></tr>
  78. <td><input type="radio" name="region" value="Peloponez" />Peloponez</td>
  79. <td><input type="radio" name="region" value="Cyklady" />Cyklady</th>
  80. <td><input type="radio" name="region" value="Macedonia Srodkowa" />Macedonia Środkowa</td>
  81. <td><input type="radio" name="region" value="Macedonia Zachodnia" />Macedonia Zachodnia</td>
  82. <td><input type="radio" name="region" value="Macedonia Wschodnia i Tracja" />Macedonia Wschodnia</td>
  83. <td><input type="radio" name="region" value="Tesalia" />Tesalia</td>
  84. <td><input type="radio" name="region" value="Sporady" />Sporady</td></tr>
  85. <tr><td><input type="radio" name="region" value="Kreta" />Kreta</td>
  86. <td><input type="radio" name="region" value="Epirus" />Epirus</td>
  87. <td><input type="radio" name="region" value="Dodekanez" />Dodekanez</td>
  88. <td><input type="radio" name="region" value="Wyspy Egejskie Północne" />Wyspy Egejskie Północne</td>
  89. <td><input type="radio" name="region" value="Wyspy Jońskie" />Wyspy Jońskie</td>
  90. <td><input type="radio" name="region" value="Wyspy Sorońskie" />Wyspy Sorońskie</td>
  91. <td><input type="radio" name="region" value="Grecja" />Cały obszar Grecji</td>
  92. </tr>
  93. <td><input type="submit" name="Wybierz" value="Wybierz"/></td>
  94.  
  95. </tr>
  96. </table>
  97.  
  98. <?php
  99.  
  100. // łączymy się z bazą danych
  101.  
  102.  
  103. // dodajemy dane stacji do bazy
  104.  
  105. if ($_POST)
  106. {
  107. if (!empty($_POST['region']) && is_scalar($_POST['region']))
  108. {
  109. $region = mysql_real_escape_string($_POST['region']);
  110.  
  111.  
  112.  
  113.  
  114. $resource = mysql_query('SELECT `name_pl`,`region`,`dzien`,`czas`,`wind_dir`,`wind_force`,`temperature`,`pressur
    e`,`lat`,`lng` FROM region
  115.  
  116. , pogoda WHERE region= "'.$region.'" AND region.station_id=pogoda.station_id ') or die(mysql_error());
  117.  
  118. while($rew=mysql_fetch_array($resource)){
  119.  
  120. echo "<table>";
  121. echo"<tr>";
  122. echo "<h4><th>" .$rew['name_pl'] ."</th></h4>";
  123. echo "<h4><th>" .$rew['region.station_id']."</th></h4>";
  124. echo "<h4><th>" .$rew['region']."</th></h4>";
  125. echo "<h4><th>" .$rew['dzien']."</th></h4>";
  126. echo "<h4><th>" .$rew['czas']."</th></h4>";
  127. echo "<h4><th>" .$rew['wind_dir']."</th></h4>";
  128. echo "<h4><th>" .$rew['wind_force']."</th></h4>";
  129. echo "<h4><th>" .$rew['temperature']."</th></h4>";
  130. echo "<h4><th>" .$rew['pressure']."</th></h4>";
  131. echo "<h4><th>" .$rew['lat']."</th></h4>";
  132. echo "<h4><th>" .$rew['lng']."</th></h4>";
  133. echo "</tr>";
  134. echo "</table>";
  135.  
  136.  
  137. }
  138.  
  139. }
  140. }
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.