Lamez Posted January 30, 2008 Share Posted January 30, 2008 I want to do this in PHP, so please do not hound me about posting in the wrong area How do I do a IF statement if a row exist? I want it to check if the row (in a table) exist and if it does delete it, and re add the new row, if it does not exist add the new row. -Thanks! Link to comment https://forums.phpfreaks.com/topic/88513-solved-in-php/ Share on other sites More sharing options...
cooldude832 Posted January 30, 2008 Share Posted January 30, 2008 if your criteria is going to meet one and only one row do <?phph $q = "Select count(*) as row_count from `Table` where this=that"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); if(mysql_num_rows($r) >0){ #The row exist } else{ #The row of the given criteria is not there } ?> Link to comment https://forums.phpfreaks.com/topic/88513-solved-in-php/#findComment-453110 Share on other sites More sharing options...
Bauer418 Posted January 30, 2008 Share Posted January 30, 2008 I understand you want to do it in PHP, however I think the MySQL syntax "REPLACE INTO" is what you're looking for. Link to comment https://forums.phpfreaks.com/topic/88513-solved-in-php/#findComment-453111 Share on other sites More sharing options...
Lamez Posted January 30, 2008 Author Share Posted January 30, 2008 nope he has the right idea, thanks! Link to comment https://forums.phpfreaks.com/topic/88513-solved-in-php/#findComment-453115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.