Database Column Array

Discussion in 'PHP' started by Pudge1, Jan 14, 2010.

  1. #1
    Can someone give me the MySQL code to make all the entries in a column into an array?
     
    Pudge1, Jan 14, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    People dont mind helping those who make an effort to learn and at least show some effort to code things. If you want to have the code written for you then you should consider hiring someone to do it
     
    JAY6390, Jan 14, 2010 IP
  3. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    I know how to code very well. I know HTML/CSS really well. And I know PHP very well. My MySQL knowledge however is not very good. I wouldn't pay someone to code this. It is a very small snippet of code. Sorry if that sounds selfish.
     
    Pudge1, Jan 14, 2010 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well the column SQL is
    SELECT `column_name_here` FROM `table_name`
    Code (markup):
    I'd really recommend you read up on mysql from w3schools or whatever if you're at the stage where you're really confident in php but not MySQL since they kinda get learnt together generally

    EDIT: Also, the array part should be the simplest for a php coder
     
    JAY6390, Jan 14, 2010 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    lol Sadly that was the only part I know. I don't really know where to go form there. I know simple things and like Sign-Up/Login things.
     
    Pudge1, Jan 14, 2010 IP
  6. kingads1

    kingads1 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if u need

    $query="select * from table_name"
    $result=mysql_query($query);
    while($row=mysql_fetch_array)//array in $row
    {
      echo $row['column_name'];//show all array of colum_name by loop
    }
    Code (markup):
     
    kingads1, Jan 14, 2010 IP
  7. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #7
    So $row is the array? So I could use like if(in_array($email,$row)) ?
     
    Pudge1, Jan 14, 2010 IP
  8. kingads1

    kingads1 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    u can use
     if(in_array($email,$row['column_email']))
    Code (markup):
    with
    $email is var $_POST in form
    $row['column_email'] is array email in your database
     
    kingads1, Jan 14, 2010 IP
  9. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #9
    Okay thanks I will try it out.
     
    Pudge1, Jan 15, 2010 IP
  10. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #10
    For some reason this creates an endless loop. Where are you getting $row from? Sorry for my stupidity. My MySQL knowledge is limited and I haven't used it for a very long time.
     
    Pudge1, Jan 16, 2010 IP
  11. kingads1

    kingads1 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    this is the code you aks
    
    $query="select * from table_name"
    $result=mysql_query($query);
    while($row=mysql_fetch_array)//get value to array from database into $row
    {
      echo $row['column_name'];//show all array of colum_name by loop
    }
    
    Code (markup):
    this is not enless loop,loop will end when it show all values in query
     
    kingads1, Jan 18, 2010 IP
  12. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #12
    Sorry I forgot to post that I got it to work. Thanks for whoever helped.
     
    Pudge1, Jan 18, 2010 IP