Now you can query the activity information of the last 5 days, but I don’t know how to traverse it. Please give me some advice.
Now you can query the activity information of the last 5 days, but I don’t know how to traverse it. Please give me some advice.
See if there is php in your tag, you can use php to connect to the database to query the results. Generally the result will be an array, just use php to traverse the array
Your ultimate goal is to bind results to a page? ?
If yes, continue.
What binding method do you use to output it directly to the page? ? Or ajax binding? ? Universal code:
<code>// 和你上面的查询的sql一致 $sql = ''; $db = new PDO('mysql:host=localhost;dbname=db_name' , $user , $pwd); $result = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC); if ($ajax) { echo json_encode($result); exit; } else { // 结合html输出 foreach ($result as $v) { // 执行相关操作.... } }</code>