dongzi3434 2014-03-12 21:27
浏览 97

通过选择日期显示mysql数据库值

if you visit here http://www.joomusic.info/joosilver.php you can understand my concept. i have set all script and calender and i make table in the mysql database table name is Firstname and there are 2 columns in this table 1, Drawtime and 2, winningnumbers. and i have made connect.php file for connected the databse

this is half script because i dont no how i make it full

<script language="JavaScript" type="text/javascript" src="calendar/calendar.js"></script>
<!--<strong><div align="right" id="timeval" style="color:#FF6600; font-family:Arial, Helvetica, sans-serif">--:--:--</div></strong>--> 
    <table width="420" border="1" >
    <form name="showdraw" action="ooo.php" method="post">
    <tr  bgcolor="#FF6600">
            <td><script> DateInput('cdate', true, 'YYYY-MM-DD'); </script></td>
            <td> <input type="submit" value ="Show"> <input type="hidden" value="Show" name="action"> </td>
    </tr>
    <tr  bgcolor="#FF6600">
        <td><h2>Draw Time</h2></td>
        <td><h2>Wining Number</h2></td>
      </tr>
    </form>
<?php
include('connect.php');

now after this include('connect.php); which php script i add in this page then my script work like this http://joomusic.info/joosilver.php

  • 写回答

1条回答 默认 最新

  • duanlu5055 2014-03-12 22:32
    关注

    Okay, well there's actually a lot to do to get it to work, but I'm going to concentrate on getting the results from the database. Basically, just pull the date value from the post string (I do not know what you named it, so I called it date). Then, pass that to your database and loop through the results. Finally format the date to just show the hours and minutes and then stick it into a table.

    // GET THE DATE FROM THE FORM
    // I DON'T KNOW WHAT THE NAME OF YOUR DATE FIELD IS, BUT CHANGE IT IN $_POST['FIELD NAME']
    $draw_date = date("Y-m-d", strtotime($_POST['date']));
    
    
    // CONNECT TO THE DATABASE - THIS SHOULD BE SET ALREADY IN YOUR connect.php
    $link = mysqli_connect('DATABASE HOST', 'USERNAME', 'PASSWORD', 'DATABASE');
    
    
    // BUILD OUT THE QUERY TO GET ALL RECORDS WITH THE SAME DRAW DATE AND ORDER THEM BY TIME
    $query = "SELECT Drawtime, winningnumbers FROM Firstname WHERE Drawtime = '".$draw_date."' ORDER BY Drawtime";
    
    
    // EXECUTE THE QUERY
    $result = mysqli_query($link, $query) or die("Cannot Get Winning Numbers");
    
    
    // START PRINTING OUT THE TABLE
    print "
            <table>";
    
    
    // LOOP THROUGH EACH OF THE RESULTS FROM THE DATABASE AND PRINT THEM OUT
    while ($row = mysqli_fetch_array($result)) {
    
        // FORMAT THE DATE SO IT IS ONLY SHOWING THE TIME
        print "
            <tr>
              <td>".date("H:i", strtotime($row['Drawtime']))."</td>
              <td>".$row['winningnumbers']."</td>
            </tr>";
    
    }
    
    // CLOSE UP YOUR TABLE
    print "
            </table>";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端