Duplication in mysql/php

Posted by user1334095 on Stack Overflow See other posts from Stack Overflow or by user1334095
Published on 2012-04-15T04:44:59Z Indexed on 2012/04/15 5:30 UTC
Read the original article Hit count: 135

Filed under:
|

I have a problem in the code.i have two tables 'sms' and 'bd_paid_bribe'.sms table has a column 'Message' and bd_paid_bribe table has a column 'c_addi_info'.when i execute the code first time all the values of Message column are inserted into c_addi_info column.when i enter a record for the second time instead of inserting the new record, all the records of Message column are inserted into bd_paid_bribe column.can u modify the code and provide a solution to avoid duplication and to insert only the newly added record.

<?php
$con=mysql_connect('localhost','root','');
if(!$con)
{
 die("couldn't connect");
 }
mysql_select_db("ipab2",$con);
$rs2=mysql_query(" select max(sms_index) from tab3");
do
{
$rs=mysql_query("insert into tab3(sms_index)select max(sms_index) from sms");
$rs3=mysql_query("SELECT max(sms_index) FROM sms");
 $rs1=mysql_query("insert into bd_paid_bribe(c_addi_info) select
Message from sms ");
 }while($rs2>$rs3);

 ?>

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql