Reputation: 487
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 ?
Upvotes: 0
Views: 97
Reputation: 219874
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
}
Upvotes: 3