Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: My Hack
- */
- function past_spreadsheet() {
- //get global database object
- global $wpdb;
- if($_POST["sheet"])
- {
- $lines = explode("\n",stripslashes($_POST["sheet"]) );
- foreach($lines as $line)
- {
- $cells = explode("\t",$line);
- //sprintf like function for formatting sql
- $sql = $wpdb->prepare("INSERT INTO my_custom_table col1=%s, col2=%s, col3=%s", $cells[0], $cells[1], $cells[2]);
- $wpdb->query($sql);
- }
- }
- else
- {
- ?>
- Paste Spreadsheet</p>
- <p><form method="post" action="roster.php"><textarea name="sheet"></textarea>
- <input type="submit" value="Submit" />
- </form>
- </p>
- <?php
- }
- } // end paste spreadsheet function
- function parts_menu() {
- add_menu_page('Paste Spreadsheet', 'Paste Spreadsheet', 1, 'paste_spreadsheet', 'paste_spreadsheet', '', 3); //add toplevel menu page
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement