Please Urgent help PHP code

Discussion in 'PHP' started by masterofzoo, Sep 28, 2011.

  1. #1
    I am now finishing my website an it is on the last touches, however I have encountered by a big problem plese help;
    In the website the user can require some data, these data follow "while"loop, for example :-

    Jean.will see these data............

    David
    Martine
    Olive

    I want to make each one of these data "variable"($)....

    N.B:-
    each one of these three names has a different ID in the database................I tried to depend on "Ascending /descending" order..........but it always the the first or last names only"David and Olive", how can I reach these in the middle as "Martine".......................Please help
     
    masterofzoo, Sep 28, 2011 IP
  2. SheetalCreation

    SheetalCreation Peon

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    3
    Trophy Points:
    0
    #2
    Your question statement is not clear to me. Do you want to say, you want to traverse through all the mysql query result.
    If yes then you can use following code :

    $result = mtsql_query(your query should come here);
    while($row = mysql_fatch_array($result)){
    here you willl have all name one by one
    david
    martin
    olive
    }

    Sheetal
     
    SheetalCreation, Sep 28, 2011 IP
  3. masterofzoo

    masterofzoo Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No I want each one of them become a variable.i,e:
    $A= david
    $b=martin
    $C= olive
     
    masterofzoo, Sep 28, 2011 IP
  4. SheetalCreation

    SheetalCreation Peon

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    3
    Trophy Points:
    0
    #4
    yeah you can get that in a variable easily
    $count = 0;
    $arr = array();
    $result = mtsql_query(your query should come here);
    while($row = mysql_fatch_array($result)){
    $arr[$count] = $row["name"]; //"name" should be replace by the actual column name for name in database.
    $count = $count + 1;
    }
    here $arr have all the names. you can traverse through $arr and get all the name.
    In your case:
    $arr[0] will have david
    $arr[1] will have martin
    $arr[2] will have olive


    Sheetal
     
    SheetalCreation, Sep 28, 2011 IP
  5. shivgupta0001

    shivgupta0001 Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    fetch by array may be that will help you
     
    shivgupta0001, Oct 4, 2011 IP