search

Home  >  Q&A  >  body text

Is there any way to implement simple queries using php+mysql?

There are 500 pieces of data in the mysql database
100 of them are date: 2017-04-20
400 are date: 2017-04-21
Is there any way to combine these two fields through PHP? The content is displayed separately
For example, when 2017-04-20 is selected on the php page, only the 100 pieces of data are displayed

How to achieve this in php

给我你的怀抱给我你的怀抱2796 days ago580

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-16 13:11:28

        global $empire;
        $query = "select * from table where date='2017-04-20'" ;
        $sql=$empire->query($query);
        while($row=$empire->fetch($sql){
            //code
            echo $row['date']
        }
    global $empire;
        $query = "select * from table where group by date" ;
        $sql=$empire->query($query);
        while($row=$empire->fetch($sql){
            //code
            echo $row['date']
        }
    
    //这样就能获得所有日期且不重复了

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:11:28

    This is very easy. Your date is a field in the data inventory? Is the value Y-m-d or Y-m-d H:i:s? No matter what it is, just query it based on time? Difficulties?

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:11:28

    It’s very simple, but it needs to be done in combination with the front end. When you select 2017-04-20, you send a request to your php through ajax. The data sent is 2017-04-20, and your php processing page only You need to receive the time, then splice the sql, query, and then return the results to the front end.

    reply
    0
  • Cancelreply