I am using the following SQL query to pull table date from another database.
$query = "SELECT option_value FROM db_name.wpm_options where option_name like 'options_go_tracking_%_tracking_pixel'";
$results = $wpdb->get_results( $query );
Everything is connecting fine and the results of the query return as expected. I am a little unsure as to how I can now loop through the results of the query, I think a foreach function is required but being a novice with sql I am having trouble proceeding.
The name of the field is "option_value", would this be used in the foreach?
My attempt to far is below, the echo is being output 10 times and there are 10 records in the sql query so I must be close, just need to output the data within the field.
$query = "SELECT option_value FROM db_nameprivate.wpm_options where option_name like 'options_go_tracking_%_tracking_pixel'";
$results = $wpdb->get_results( $query );
if($results):
foreach($results as $row): setup_postdata($row);
echo "output";
// Trying to output the results of query here, the content of each "option_value" field
endforeach;
else: '.echo "No Records Found".';
endif;