dtu72460 2012-08-02 15:09
浏览 52
已采纳

MySQL选择困难

this may be very easy to do but I do not even know how to formulate my problem for search engines (google | stackoverflow).

I am trying to create a HTML form based on data from database.
my problem:
I have table with these columns:

  1. id
  2. file
  3. language
  4. etc...

filled with data (example):

//no < table > here
//only **file** column is really important for my select (that I am asking for)

id |    file            |  lanugage     | etc
====================================================================
1  |about.php           | english       | something
2  |conta.php           | english       | something
3  |mysql.php           | hungar        | something
4  |mysql.php           | english       | something
5  |mysql.php           | french        | something
6  |blog.php            | french        | something

after the select I am asking for array should look like this

0 => about.php, 1 => conta.php, 2 => mysql.php, 3 => blog.php



SOLUTION
I was looking for distinct option of SELECT
or
SELECT t1.file as Files from table as t1 group by Files

well this was fast :) thanks

  • 写回答

5条回答 默认 最新

  • donglu4633 2012-08-02 15:14
    关注

    It sounds like you want to

    SELECT distinct(file) FROM mytable;
    

    and then use

    mysql_fetch_array()

    something like that:

    $result=mysql_query("SELECT distinct(file) FROM mytable");
    $arr=array();
    while($row = mysql_fetch_array($result)){
        $arr[] = $row[0];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大