ds1379551 2015-05-25 11:37
浏览 18

我想选择1列MySQL表行

I have a made a MySQL table, and I've been trying to make it answer on my site. As for now, it picks all the columns in my rows, and I wanted to pick a specific column.

Does anyone know a better way to make it echo on your page?

<?php
$data = "SELECT * FROM anmeldelser";

$result = $connection->query($data);



while($row = $result->fetch_array()){

    echo "<b>Kundenavn:&nbsp;</b>" . $row['Kundenavn'] . "<b>&nbsp;Kommentar:&nbsp;</b>" . $row['Kommentar'] . "<b>&nbsp;Dato:&nbsp;</b>" . $row['Dato'];

}

?>`

This gives the result of every row in my db. I want to pick one random or just be specific about which one I want to place in which div.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doutao1282 2015-05-25 11:42
    关注

    i found a solution myself.

    $data = "SELECT * FROM mytabel WHERE name = 'Steve'";
    

    To select the next, you copy the line and type the next name of your tabel.

    $data = "SELECT * FROM mytabel WHERE name = 'Bob'";
    

    Which makes it echo only one of the columns.

    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程