Column Value Blues

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Heath

    #1

    Column Value Blues

    Howdy,

    I am really struggling with the basics here.

    PHP/MySQL

    I have a database with three columns:

    ID, Name, Phone

    I want to return all the unique items in Name.

    My Query is

    $result = mysql_query ( "SELECT Name FROM database")

    Let's say there are 20 entries. I want to return all twenty entries with
    a <br /> between them.

    I have tried to use foreach and while with mysql_fetch_row & _array, but
    I can't get it to work. Can anyone help?

  • Garp

    #2
    Re: Column Value Blues


    "Heath" <heathweaver@be lgacom.net> wrote in message
    news:40bb57d1$0 $9529$a0ced6e1@ news.skynet.be. ..[color=blue]
    > Howdy,
    >
    > I am really struggling with the basics here.
    >
    > PHP/MySQL
    >
    > I have a database with three columns:
    >
    > ID, Name, Phone
    >
    > I want to return all the unique items in Name.
    >
    > My Query is
    >
    > $result = mysql_query ( "SELECT Name FROM database")
    >
    > Let's say there are 20 entries. I want to return all twenty entries with
    > a <br /> between them.
    >
    > I have tried to use foreach and while with mysql_fetch_row & _array, but
    > I can't get it to work. Can anyone help?[/color]

    Unique items:
    $result=mysql_q uery("SELECT DISTINCT Name FROM table");

    Separate data retrieval from presentation - add your <br /> during the
    output stage. With apologies to the help for mysql_fetch_arr ay():

    while ($row = mysql_fetch_arr ay($result)) {
    printf ("Name: %s<br />", $row[0]);
    }

    Garp


    Comment

    Working...