[insert_php]
$path = $_SERVER[‘DOCUMENT_ROOT’];
$path .= ‘/wp-config.php’;
require_once($path);

$conn = new mysqli (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

if( isset( $_GET[‘tournid’] ) ) {

$tid = $_GET[‘tournid’];
settype($tid, “int”);

$sql = “SELECT * from tournaments where tourn_id = ‘”.$tid.”‘”;
$query = mysqli_query($conn, $sql);

$sql2 = “SELECT age_level from age_levels inner join tourn_age on age_levels.age_id = tourn_age.age_id where tourn_age.tourn_id = ‘”.$tid.”‘”;
$query2 = mysqli_query($conn, $sql2);

if (!$query) {
die (‘SQL Error: ‘ . mysqli_error($conn));
}
$row2 = mysqli_fetch_row($query);
$venue = $row2[1];
echo

‘.$venue.’

Start Date: ‘.$row2[2].’
End Date: ‘.$row2[3].’

‘.$row2[4].’
‘.$row2[5].’
‘.$row2[6].’, TX ‘.$row2[7].’

Meet Contact: ‘.$row2[11].’
Phone: ‘.$row2[12].’

Style: ‘.$row2[14].’

Gender: ‘.$row2[8].’

Region: ‘.$row2[13].’

‘;
if ($row2[5]) {
$mapadd = ‘https://maps.googleapis.com/maps/api/geocode/json?address=’.str_replace(” “, “+”, $row2[5]).’,+’.str_replace(‘ ‘, ‘+’, $row2[6])
.’,+TX&key=AIzaSyCC1OdAVr1i9-O97mw4v4Xtwxciz7XMvyI’;
$addrinfo = wp_remote_retrieve_body(wp_remote_get($mapadd));
$data = json_decode($addrinfo);
$lat = $data->results[0]->geometry->location->lat;
$lng = $data->results[0]->geometry->location->lng;
}
$ages = ”;
while ($row = mysqli_fetch_array($query2))
{
$ages = $ages.$row[‘age_level’].’, ‘;
}
echo ‘

Ages: ‘.substr($ages,0,-2).’

‘;
if ($row2[9]){
echo ‘

Meet Website or Flyer

‘;
} else {
echo ‘

Meet website or flyer is not available at this time

‘;
}
if ($row2[10]){
echo ‘

Click Here to Register

‘;
} else {
echo ‘

Registration is not yet available

‘;
}
echo ‘

‘;

}
[/insert_php]