HOw Do I update from table-2 to table-1

Posted by mathew on Stack Overflow See other posts from Stack Overflow or by mathew
Published on 2010-05-18T06:45:28Z Indexed on 2010/05/18 6:50 UTC
Read the original article Hit count: 222

Filed under:
|

HI what is the wrong in this code?? i have set it 24 hours to update the value in the table.but the problem is if $row is empty then it inserts value from table-2 but after 24 hours it wont update the value.

what I want is it must delete the existing value and insert new one(random value) or it must update the same $row with new value what ever...

if ($row == 0){ mysql_query("INSERT INTO table-1 
(regtime,person,location,address,rank,ip,geocode) SELECT NOW(),person,location,address,rank,ip,geocode FROM table-2 ORDER BY RAND() LIMIT 1");}else{ mysql_query("UPDATE table-1 SELECT regtime=NOW(),
                     person=person,
             location=location,
             address=address,
             rank=rank,
             ip=ip,
             geocode=geocode FROM table-2 ORDER BY RAND() LIMIT 1");}

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql