Inside table(1)
ID Name Address Phone InsertDate
1 Andrew 12-A,ABC 576849203 2014/05/06
1 Andrew 12-A,ABC 123456789 2014/07/08
Inside table(2)
ID Name Address Phone InsertDate
1 Andrew 12-A,ABC 123456789 2014/07/08
The problem I met is when I Select * from table(1) where id='1'. It will retrieve two records. Then when I try to insert to table(2). It only show one record in table(2) instead of 2 records.
What should I do so I can get the two records from table(1) and insert to table(2)?
My example Code:
$mysql="Select * from table(1) where id='1'";
**Perform the query**
**Retrieve values**
$sth->bind_col(1, \$Name);
$sth->bind_col(2, \$Address);
$sth->bind_col(3, \$Phone);
$sth->bind_col(4, \$InsertDate);
if($sth->fetch()){
$mysql="Insert into table(2) values($Name,$Address,$Phone,InsertDate)";
**Perform the query**
}
Thanks for viewing,comments and answers!
if($sth->fetch())=>while($sth->fetch()), and use placeholders to fetch and insert. perlmonks.org/?node_id=284436