sql traversal results

WBOY
Release: 2016-09-06 08:57:10
Original
1304 people have browsed it

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.
sql traversal results

sql traversal results

Reply content:

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.
sql traversal results

sql traversal results

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template