duankeng2026 2011-11-13 21:12
浏览 34
已采纳

如何正确地从数据库中检索

I am new to PHP and I am having issues pulling this data in.. It is finding the records according to the debugger but then for some reason the page comes blank. Can anyone please help me with this for loop to retrieve the fields?, i think this is where the issue is. I tried with and without that while loop (which i think is wrong there) and nothing

 echo '<table class="table_content">
             <tr>
                 <td class="td_order" colspan="3" width="800px">
              Descriptions                  </td>
           </tr><tr>';

    for($counter = 0; $row2 = mysql_fetch_row($result2); $counter++)
                  {

                   while ($row2 = mysql_fetch_assoc($result)) {
                          $_name = $row["_name"];
                          $_image = $row["_image"];
                          $_disc = $row["_disc"];
                      }
                        print("<td valign='top' width='230px' height='300px'>");
                        print("<p style='font-size:18px; color:blue; padding:0;'>$_name</p>");
                        print("<img class='custom' alt='' src='$_image'/>");
                        print("<p>$_disc</p>");
                       print('</td>');
                    }
                  }

           echo '</tr></table> ';

I think I am doing something wrong with this logic for the loop, I have tried several things.. but nothing... I would appreciate your help.

PS: The connections works, the query works.. The data being retrieve is as foollow

_name        _image                _disc   
Benjamin    images/benjamin.jpg    He's a great person
Jairo       images/jairo.jpg       Jairo has experience as a civil engineer..
  • 写回答

4条回答 默认 最新

  • douduan9129 2011-11-13 21:20
    关注

    Remove the for and while loop and change it with ;

    while($row = mysql_fetch_array( $result )){
       $_name = $row["_name"];
       $_image = $row["_image"];
       $_disc = $row["_disc"];
       ..
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效