Home > Backend Development > PHP Tutorial > PHP调用数据库数据输出结果总重复一次

PHP调用数据库数据输出结果总重复一次

WBOY
Release: 2016-06-13 13:35:20
Original
1027 people have browsed it

求助:PHP调用数据库数据输出结果总重复一次。
表里有两条内容:
1111111111111111111111111
2222222222222222222222222

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php //设置数据库变量
$db_host   = 'localhost';
$db_user   = 'root';
$db_passw = '123456';
$db_name  = 'freebb';

$conn = mysql_connect($db_host,$db_user,$db_passw) or die ('数据库连接失败!');
mysql_query("set names 'utf8'");

mysql_select_db($db_name,$conn) or die('数据库选定失败!');
$sql = "SELECT * FROM `member` ORDER BY `id` DESC LIMIT 0, 16";

$result = mysql_query($sql) or die('数据库查询失败!');

  while($mem = mysql_fetch_object($result)) //循环开始
{
    $username = $mem->username;
      $bbsname = $mem->bbsname;
    $bbstype = $mem->bbstype;
?>

              
Copy after login
  • []


  • 输出显示内容为:
    11111111111111111111111111
    22222222222222222222222222
    11111111111111111111111111
    22222222222222222222222222

    请问这是怎么回事呢,求解

    ------解决方案--------------------
    探讨

    引用:
    引用:

    引用:
    while($mem = mysql_fetch_assoc($result)) //循环开始
    {
    echo $men['username'];
    echo $men['bbsname'];
    }

    这样会重复吗?看看
    ?>


    这样显示空白了 不能输出


    在循环里 var_dump($m……

    ------解决方案--------------------
    box.innerHTML+=box.innerHTML;这句的问题
    这样假设 box.innerHTML 为 '111';
    那么 box.innerHTML+=box.innerHTML; 后,box.innerHTML 为 '111111';
    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