Created
February 27, 2012 06:08
-
-
Save ctrl-freak/1921833 to your computer and use it in GitHub Desktop.
Flexible Query Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| function submit() | |
| { | |
| $fields = array( | |
| 'first_name', | |
| 'last_name', | |
| 'email', | |
| 'phone' | |
| ); | |
| $fields_user=array( | |
| 'gender', | |
| 'birthday', | |
| 'display_name' | |
| ); | |
| $fields_moderator = array( | |
| 'gender', | |
| 'birthday', | |
| 'display_name', | |
| 'position_title' | |
| ); | |
| $fields_administrator = array( | |
| 'gender', | |
| 'birthday', | |
| 'display_name', | |
| 'position_title', | |
| 'show_online', | |
| ); | |
| $fields_staff = array( | |
| 'position_title', | |
| 'show_online' | |
| ); | |
| $fields = array_merge($fields, ${'fields_'.$_SESSION['member']['member_type']}); | |
| foreach($fields as $f) | |
| { | |
| if (isset($_POST[$f])) { | |
| if (is_array($_POST[$f])) { | |
| } else { | |
| $set[] = $f .' = "'. mysql_real_escape_string($_POST[$f]) .'"'; | |
| } | |
| $data[$f] =$_POST[$f]; | |
| } | |
| } | |
| $query = 'UPDATE members SET '. implode(', ', $set) .' WHERE id='. $_SESSION['member']['id']; | |
| query($query); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment