Swimmers

[insert_php] if ( (isset($_GET[‘keyword’])) ) {
$keyword = $_GET[‘keyword’];
}
elseif ( (isset($_POST[‘keyword’])) ) {
$keyword = $_POST[‘keyword’];
} else { //No valid membership number, kill the script.
echo ‘

Ooops.. looks like you made a mistake! Best go back…

‘;
exit();
}
include (‘/websites/ma/manlyswimclub.org.au/wp/wp-includes/variables.inc’);
require_once(‘/websites/ma/manlyswimclub.org.au/wp/wp-includes/mysqli_connect.php’); //Connect to the DB

$current_url = $_SERVER[“REQUEST_URI”];

// Make the query:

$q = “Select $membership_table.membership_number AS member, $membership_table.swimmer_lastname AS lastname, $membership_table.swimmer_firstname AS firstname, DATE_FORMAT($membership_table.swimmer_dob, ‘%d-%m-%Y’) AS dob, $membership_table.swimmer_sex AS sex, $swimmer_table.category AS age FROM $membership_table INNER JOIN $swimmer_table ON $membership_table.membership_number = $swimmer_table.membership_number WHERE swimmer_lastname LIKE’%$keyword%’ OR swimmer_firstname LIKE ‘%$keyword%’ ORDER BY member ASC”;

$r = @mysqli_query ($dbc, $q); // Run the query

//Count the number of records:

$num =@mysqli_num_rows($r);

if ($num>0) { // If it ran OK, display the records.

echo “

Yeah.. We found $num swimmer(s)!

“;
// Table header.
echo ‘

‘;

// Fetch and print all the records

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
echo ‘

‘;

} // End of WHILE loop

echo ‘

Member No. Last Name First Name
‘ . $row[‘member’] . ‘ ‘ . $row[‘lastname’] . ‘ ‘ . $row[‘firstname’] . ‘

‘; // Close the table.
mysqli_free_result($r); // Free up the resources.
mysqli_close($dbc); // Close the database connection.
}
[/insert_php]