iPixel Posted September 12, 2009 Share Posted September 12, 2009 Ok, to keep a long story short. I have a database with two fields. Date & Info. I've got mostly everything done now i just need to enter the data into the database via php. Question... what is the syntax to check if a record with a DATE that's passed already exists. I want to INSERT if it doesn't exist and UPDATE if it does. Link to comment https://forums.phpfreaks.com/topic/174034-solved-probably-a-noob-phpmysql-query-question/ Share on other sites More sharing options...
Garethp Posted September 12, 2009 Share Posted September 12, 2009 if(!mysql_num_rows(mysql_query("SELECT * FROM `table` WHERE `DATE`='$Date'"))) { mysql_query("DO INSERT HERE"); } Link to comment https://forums.phpfreaks.com/topic/174034-solved-probably-a-noob-phpmysql-query-question/#findComment-917384 Share on other sites More sharing options...
iPixel Posted September 12, 2009 Author Share Posted September 12, 2009 Heh i suppose that will do, i was thinking of some sort of IF EXISTS like when they do so in table creation. But this will do just fine. TY. Link to comment https://forums.phpfreaks.com/topic/174034-solved-probably-a-noob-phpmysql-query-question/#findComment-917385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.