boon_chong Posted January 3, 2007 Share Posted January 3, 2007 I got 2 tables, punch1 and punch2, why the record in punch1 can't insert into punch2? table punch1:[table][tr][td]employeeID[/td][td]punch1[/td][td]date[/td][td]outlet[/td][/tr][/table]table punch2:[table][tr][td]employeeID[/td][td]punch2[/td][td]date[/td][td]outlet[/td][/tr][/table][code]<?include("8_dbconnect.php");$sql = "select * from punch1";$result = mysql_query($sql, $mysql_link);$sql2 = "select * from punch2";$result2 = mysql_query($sql2, $mysql_link);while($row = mysql_fetch_array($result)){if (punch1.date !=punch2.date){$i1 ="insert into punch2 (employeeID,punch2,date,outlet) values ($row[employeeID],$row[punch1],$row[date],$row[outlet])";$result3= mysql_query($i1, $mysql_link);}}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32655-cant-insert-please-help/ Share on other sites More sharing options...
ted_chou12 Posted January 3, 2007 Share Posted January 3, 2007 I dont quite understand what you are trying to do here:$result = mysql_query($sql, $mysql_link);please explain,ThanksTed Quote Link to comment https://forums.phpfreaks.com/topic/32655-cant-insert-please-help/#findComment-151954 Share on other sites More sharing options...
Jessica Posted January 3, 2007 Share Posted January 3, 2007 What errors do you get? If the values in the arrays are strings you need to put '' around them, so you'll have to do a lot of fancy quote marking to get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/32655-cant-insert-please-help/#findComment-151970 Share on other sites More sharing options...
boon_chong Posted January 3, 2007 Author Share Posted January 3, 2007 what I'd like to do is trace the record in table punch1 whether exist in table punch2, if the condition is true then insert the record in table punch1 into table punch2. i'm not sure i'm using the right coding or not. There is no error come out, but the record can't insert. Quote Link to comment https://forums.phpfreaks.com/topic/32655-cant-insert-please-help/#findComment-151974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.