From PHP Mysql query to javascrip
-
Hello,
Im trying to make a search on my mysql database using php. That result I want to get pass it to javascript. The code I’m using now is in PHP:global $wpdb; $table_name = $wpdb->prefix . "skapa_courses"; $current_user = wp_get_current_user(); $sql = "SELECT * FROM <code>$table_name</code> WHERE <code>owner</code> = '$current_user->ID'"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $results = $wpdb->get_results($sql); wp_localize_script( 'java_script_file', 'object_name', $results );
then in my java_script_file I need something similar like I do in php. Something like:
foreach ( $results as $result ) { echo $result->course_name; echo $result->participants; echo $result->date; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘From PHP Mysql query to javascrip’ is closed to new replies.