While it is VERY bad practice to have spaces in the object names, there are times where it may be out of your control. You can use the syntax of $object->{'Property Name'}
, like this:
// add the shortcode [pontoon-table], tell WP which function to call
add_shortcode( 'pontoon-table', 'pontoon_table_shortcode' );
// this function generates the shortcode output
function pontoon_table_shortcode( $args ) {
global $wpdb;
// Shortcodes RETURN content, so store in a variable to return
$content="<table>";
$content .= '</tr><th>Week Beginning</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th><th>Weekly Total</th><th>Previosu Week Total</th></tr>';
$results = $wpdb->get_results( ' SELECT * FROM wpdb_PontoonBoats_LineOne_2Log' );
foreach ( $results AS $row ) {
$content .= '<tr>';
// Modify these to match the database structure
$content .= '<td>' . $row->{'Week Beginning'} . '</td>';
$content .= '<td>' . $row->Monday . '</td>';
$content .= '<td>' . $row->Tuesday . '</td>';
$content .= '<td>' . $row->Wednesday . '</td>';
$content .= '<td>' . $row->Thursday . '</td>';
$content .= '<td>' . $row->Friday . '</td>';
$content .= '<td>' . $row->Saturday . '</td>';
$content .= '<td>' . $row->Sunday . '</td>';
$content .= '<td>' . $row->{'Weekly Total'} . '</td>';
$content .= '<td>' . $row->{'Previous Week Totals'} . '</td>';
$content .= '</tr>';
}
$content .= '</table>';
// return the table
return $content;
}
UPDATE:
It looks like you had $content="<tr>";
which resets the string instead of appending to it, changed that to $content .= '<tr>';