coldfission Posted May 5, 2007 Share Posted May 5, 2007 I have a database full of order records for our website. My goal is to delete people from the same 'address' field and add up the 'total' into one record. Can i get some example code on how this would be done? Quote Link to comment https://forums.phpfreaks.com/topic/50150-php-database-delete-repeat-records-and-add-up-totals/ Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 try SELECT email FROM users GROUP BY email HAVING ( COUNT(email) = 1 ) Quote Link to comment https://forums.phpfreaks.com/topic/50150-php-database-delete-repeat-records-and-add-up-totals/#findComment-246242 Share on other sites More sharing options...
coldfission Posted May 5, 2007 Author Share Posted May 5, 2007 OK i used that in my code, but not I need to search WHERE address=$address. But, some poeple typed their address in with single or double quotes. How would I delete all characters that would mess up the query? I was looking at the ereg_replace, but i couldn't figure it out thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/50150-php-database-delete-repeat-records-and-add-up-totals/#findComment-246279 Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 my last post was for an MySQL Query, to clean up the input to the database you can use addslashes($data) if you did want to clear out the quotes via ereg_replace (not need with add slashes) but i think this would do it $data = "hello's" $result = ereg_replace("\"'", '', $data); Quote Link to comment https://forums.phpfreaks.com/topic/50150-php-database-delete-repeat-records-and-add-up-totals/#findComment-246322 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.