is it possible to put data from a text file into input type

Discussion in 'Programming' started by MrPJH, Jan 13, 2011.

  1. #1
    is it possible to put data from a text file into input type
    <input type="text" name="phone" size="33" value="<?php echo stripslashes($phone); ?>">
    PHP:
    $phone have value
    $lines = file('phones.txt');
    foreach($lines as $num => $phone){
    PHP:
    stripslashes is necessary as the data added with addslashes
    currently it gets only the last line of phones.txt
     
    MrPJH, Jan 13, 2011 IP
  2. loog12us

    loog12us Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Read the file and then
     
    loog12us, Jan 13, 2011 IP
    MrPJH likes this.
  3. MrPJH

    MrPJH Well-Known Member

    Messages:
    1,066
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    155
    #3
    Thanks loog12 but it copies all phones in one line
    not each line
     
    MrPJH, Jan 14, 2011 IP
  4. loog12us

    loog12us Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hope it helps
     
    loog12us, Jan 15, 2011 IP
  5. MrPJH

    MrPJH Well-Known Member

    Messages:
    1,066
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    155
    #5
    i tried this but this copies only the last line from the text file
     
    MrPJH, Jan 15, 2011 IP
  6. BreezeTR

    BreezeTR Well-Known Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #6
    what is phones.txt in?
     
    BreezeTR, Jan 15, 2011 IP
  7. MrPJH

    MrPJH Well-Known Member

    Messages:
    1,066
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    155
    #7
    numbers like
    123
    321434
    344365
    5657
    7687687
    678678
     
    MrPJH, Jan 16, 2011 IP
  8. Rudolf Bodocsi

    Rudolf Bodocsi Peon

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi,

    You can't use <input type="text"> tag to display multi-line text. If you want to display multi-line text then you need to use <textarea rows="" cols=""> tag.
    Or if you want to display every data in new <input type="text"> tag ?

    Rudolf
     
    Rudolf Bodocsi, Jan 17, 2011 IP
  9. clumbiecom

    clumbiecom Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    you can use array
    $lines = file('phones.txt');
    echo $lines[1];
    echo $lines[2];
    .
    .
    .
     
    clumbiecom, Jan 24, 2011 IP