0

I put telephone number in MySql database like this :

  id  |           number              |

   1  | 123456789-987654321-987456123 |
   2  | 858555588-859654744-965854777 |
   3  | 369587774-369855214-369852147 |

now i need to print for each id list of each telephone number like this:

<input type="text" id="p_scnt" size="20" name="phone[]" value="<?PHP echo  $row['phone'];?>" />

i think first separated using explode() function and than print array();

how to can i print this ?

1 Answer 1

3

Use explode() to break the string apart at the dash. Then just loop through the array of numbers echoing out each one as the value of the input.

$numbers = explode('-', $row['number']);
foreach ($numbers as $number) {
?>
    <input type="text" id="p_scnt" size="20" name="phone[]" value="<?PHP echo  $number;?>" />
<?php
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.