This is part of adding a shortcode for WordPress. In my query, the ‘players’ field will have 3 to 4 names in it. I know how to explode it and re-create the list as I want it, but not within this function for some reason.
It has to use Return.
function team_players( $atts, $content ) {
$a = shortcode_atts( array(
‘team’ => ‘’,
), $atts );
if ( empty ( $a[‘team’] )) {
return ‘Empty’;
}
$team = $a[‘team’];
$query = "SELECT * FROM a_game_preview_players
where teamID = '" . $team . "'";
$results = mysqli_query($con,$query);
echo mysqli_error($con);
while($row = mysqli_fetch_assoc($results)) {
return '<b>' . $row['school'] . '</b><br/>'
. $row['players'];
}
}
add_shortcode(‘players’, ‘team_players’);
I’ve tried several things, including using echo instead of return.