I have two problems with WordPress.
First I am trying to create a database table with the prefix "ol" but when I add an email into my form, there is no new table created in the databaze. Here is the code:
if ( isset( $_POST['ol-odeslat'] ) ) {
$name = sanitize_text_field( $_POST["ol-name"] );
$email = sanitize_email( $_POST["ol-email"] );
require_once('../../../wp-config.php');
global $wpdb;
$table_name = $wpdb->prefix . "ol";
$wpdb->insert( $table_name, array( 'name' => $_POST['ol-name'], 'email' => $_POST['ol-email'] ) );
}
Also I am trying to create a table in WordPress admin but I seem to be getting an error that there is an unexpected . (dot) on the line 171. Here is the code:
$sql = "SELECT name,email FROM 'ol' ";
$results = $wpdb->get_results($sql);
if ($results) {
foreach ($results as $row) {
echo '<tr>';
echo '<th>' . $row->name; . '</td>';
echo '<td>' . $row->email; . '</td>';
echo '</tr>';
}
}