Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach($_POST as $key => $value){
- if($key != 'update-areas-module-submit' && $value != ''){
- $key = explode(',', $key);
- $textExists = $wpdb->get_results("SELECT * FROM areas_module_text WHERE relation = '".$key[0]."' AND state = '".$key[2]."'");
- $urlExists = $wpdb->get_results("SELECT * FROM areas_module_urls WHERE relation = '".$key[0]."' AND state = '".$key[2]."'");
- if($textExists || $urlExists){
- if($key[1] === 'text'){
- $wpdb->update(
- 'areas_module_text',
- array(
- 'text' => $value,
- ), array('relation' => $key[0], 'state' => $key[2]));
- }else if($key[1] === 'url'){
- $wpdb->update(
- 'areas_module_urls',
- array(
- 'url' => $value,
- ), array('relation' => $key[0], 'state' => $key[2]));
- }
- }else{
- if($key[1] === 'text'){
- $wpdb->insert(
- 'areas_module_text',
- array(
- 'text' => $value,
- 'state' => $key[2],
- 'relation' => $key[0]
- ));
- }else if($key[1] === 'url'){
- $wpdb->insert(
- 'areas_module_urls',
- array(
- 'url' => $value,
- 'state' => $key[2],
- 'relation' => $key[0]
- ));
- }
- }
- }
- }
- echo '<div class="updated"><p>Updated successfully!</p></div>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement