查询语句有异常,找了好久都没有发现,哪位高手帮小弟我看看

WBOY
Release: 2016-06-13 13:13:32
Original
896 people have browsed it

查询语句有错误,找了好久都没有发现,谁帮我看看!
我设的条件是number=512在数据库中符合条件的只有一条记录,但每次遍历输出把所有的数据都输出了?
一直都找不到原因.

PHP code
<!--

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

-->      
         $sql = "select * from `test` where number=512";
    $sqlm = mysql_query($sql);
    while($row = mysql_fetch_array($sqlm)){
  ?>
  <tr>
    <td id="photo" rowspan="6"><img  src="" alt=" 查询语句有异常,找了好久都没有发现,哪位高手帮小弟我看看 " ></td>
    <td class="td1">姓名:</td>
    <td class="td2"><?php echo $row[name];?></td>
    <td class="td1">性别:</td>
    <td class="td2"><?php echo $row[sex];?></td>
  </tr>
   <tr>
    <td class="td1">出生日期:</td>
    <td class="td2"><?php ?></td>
    <td class="td1">年龄:</td>
    <td class="td2"><?php ?></td>
  </tr>
   <tr>
    <td class="td1">现居地:</td>
    <td colspan="3" class="td2"><?php ?></td>
  </tr>
  <tr>
    <td class="td1 td3">备注:</td>
    <td colspan="3" class="td2"><?php ?></td>
  </tr>
<?php }
?>
Copy after login


------解决方案--------------------
可以先打印sql 语句先。然后再放到phpmyadmin 里运行下看看sql有没有错。。。
------解决方案--------------------
在 phpmyadmin 中执行你的 sql
贴出结果
------解决方案--------------------
number是varchar形式。
sql语句应该是$sql = "select * from `test` where number='512'";
------解决方案--------------------
处理字符串的时候必须加引号,或者你可以把这个字段改为int类型。
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