You are getting illegal string offset 'timeslot'
because $time
is not an array, it is an item in array $timeslots
. You have already retrieved the values submitted using $timeslots = $_POST['timeslot'];
Your code also contains other typing mistakes.
Here is corrected code:
<form method="POST">
<select name="timeslot[]" multiple="multiple" size = 4 required>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="submit" name="submit"/>
</form>
<?php
if(isset($_POST['submit'])){
global $wpdb;
$booking_timeslots = $wpdb->prefix . 'booking_timeslots';
$timeslots = $_POST['timeslot'];
// you can use print_r() here
print_r( $timeslots ); // to see what is submitted from form
foreach ($timeslots as $time) {
echo $time;
}
}
?>
I hope this helps.
Related Posts:
- What are the differences between WPINC and ABSPATH?
- Using require_once in a Plugin?
- Making plugin unique to not conflict with plugins with the same name
- How to find out if option exists but is empty?
- Errors while using ajax from external wordpress page
- shortcode doesn’t work
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Scope for PHP Variables Assigned in functions.php or a plugin
- Plugin Development sqlite or WordPress’ database
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Where should I save an API key of my user when installing my plugin?
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- WP Post Template – Templates in own folder
- wordpress plugin is not activating from widget
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Image upload and download from front-end
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- What are the specifics of WordPress development I need to know? [closed]
- Ajax call returning 0
- WP All Import – Execute Imports
- How to replace WordPress Media Upload Window with user’s device window?
- Conditional attributes and logic per product category
- How to create a custom post type that contains another custom post type?
- Setup wp_schedule_event within a custom plugin
- Issue running db create table query from static method
- execute function after one completed
- How to make multiple admin pages for one plugin?
- Include a php file from another plugin
- Integrating boxtal PHP library into a custom WordPress Plugin
- How to create plugin/ page that reads from database
- Save user total active time after login in wordpress [closed]
- Switch from wp-cron to a server cron job
- Why is it important to check for isset and is_array before checking in_array in this example?
- How to add/change (woocommerce) product tab icon
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- Calling a save function from a “submit” button
- Wp Debug Enabled True Notices and Warning
- How to call external functions from a PHP script in a WordPress plugin?
- How to write to a separate PHP file in plugin settings
- Create “new pages” within the admin section of plugin
- More gentle way to hook WordPress custom url
- How to display results from a data table with an encrypted user id?
- How to add custom function to pluggable.php
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- save_post_product action not firing
- How to get the custom field value using SQL query
- Unexpected add action function in WP plugin
- admin_notices show after load completed
- Prevent WordPress from sending set-cookie http header
- Cookie value changes back to previous value after changing
- How use wp_insert_post and add og:custom tags?
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- WordPress rewrite rule depend on meta values not ids
- How to change “Read More” text?
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- Problem with wordpress has_action() function
- Offering a freemium plugin (a free version + paid version)
- Using id to show item
- 500 Internal server error wp_handle_upload_prefilter
- Can’t access 3rd party API, code works on local server but not on wordpress
- Generate and send ICS file through WordPress
- Get post content inside plugin class method
- Is admin section completely customizable in terms of styling?
- Change pricing in Woocommerce based on Category and Product [closed]
- WordPress environment not loading properly
- WordPress not displaying information on post sent from custom admin form
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Creating a user ‘add custom field’ section
- Autoloading a PHP class – working outside, but not inside WordPress plugin
- Saving an array to get_options
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- How to add a handler for a button in plugin?
- Doing action based on input from options menu
- Help me with my first very basic plugin
- Load my plugin before cache
- How use Dynamic hyperlink on each wordpress post?
- My wordpress website admin panel loads very slow, what can i do about that? [closed]
- How to create post comparison in wordpress
- What can I do to customize a widget provided with this plugin? from where have I to start?
- How to add custom html to the Media > Attachment Details modal?
- Function not being called on form submit, only blank admin-post.php page
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How to override plugin function in code snippets WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress
- WordPress Throwing Deprecated Errors on its own Files
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- plugin doesn’t retrieve data from database