session_start(); error_reporting(E_ALL); ini_set('display_errors', '0'); //Connecting to database $dbhost = 'localhost'; $dbuser = 'bptraining_admin'; $dbpass = 'Blr1gbattlemaster'; $dbname = 'blue_path_training'; $conn = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname); if(! $conn ) { die('Could not connect: ' . mysqli_error()); } // set nav dropdown name $nav_dropdown_name = "tools"; // set nav page name $nav_page_name = "tools_tutorials"; // include content functions include("functions/functions_content.php"); // number of courses per page $number_of_courses_per_page = 12; // get the content id for courses $result_content_type_id = mysqli_query($conn, "SELECT content_type_id FROM content_types WHERE content_type = 'Course'"); while ($query_data_content_type_id = mysqli_fetch_assoc($result_content_type_id)) { $content_type_id = $query_data_content_type_id["content_type_id"]; } // if it's set, load up the page variable and offsets $page = 1; $page_offset_text = ""; if(isset($_GET["page"])) { $page = $_GET["page"]; } if ($page > 1) { $query_offset = ($page - 1) * $number_of_courses_per_page; $page_offset_text = " OFFSET " . $query_offset; } ?>
print_r( array_values($array_categories_content)); ?>
print_r( array_values($array_levels_content)); ?>
print_r( array_values($array_classes_content)); ?>
-------------
*/ // set up the final content array and query // first determine how many we have checked // if we have none, then show everything // if we have one, show everything checked // if we have more than one, then we need to create a variable set of array variables to pull in the correct tables. $has_values_checked_total = $has_values_categories + $has_values_levels + $has_values_classes; if($has_values_checked_total == 0) { // do nothing, let the main query run. } elseif($has_values_checked_total == 1) { // merge all of the arrays to catch the one that is populated $final_content_array = array_merge($array_categories_content, $array_levels_content, $array_classes_content); } else { // if more than one of the categories is checked, then we need to intersect the arrays in order // to get only the ones that apply to all three categories. $args = array(); if ( !empty($array_categories_content) ) $args[] = &$array_categories_content; if ( !empty($array_levels_content) ) $args[] = &$array_levels_content; if ( !empty($array_classes_content) ) $args[] = &$array_classes_content; if ( count($args) == 1 ) { $final_content_array = $args[0]; } else { $final_content_array = call_user_func_array('array_intersect', $args); } } ?>
// add the content ids to the query by throwing an and / or
// shooting for WHERE blah = blah AND (content_id = 1 OR content_id = 2 OR content_id = 3)
// set the or_conditions to nothing and set the or_conditions_trigger to 0 and the first_or = 0
$or_conditions = "";
$or_conditions_trigger = 0;
$first_or = 1;
foreach($final_content_array as $key => $value)
{
// echo " content id |" . $value . "
";
// add to the or_conditions
if ($first_or == 0)
{
// if this is not the first or, add the or to the statement
$or_conditions = $or_conditions . " OR content.content_id = " . $value;
}
else
{
// if this IS the first or, add the or to the statement without the OR
$or_conditions = $or_conditions . " content.content_id = " . $value;
// now that we've processed the first or , set the first_or variable to 0
$first_or = 0;
}
// set the or_conditions_trigger to 1
$or_conditions_trigger = 1;
}
// if the or_conditions trigger is 1 (there were entries in the or) then add the front and back ends
// so that it fits nicely in the query. Otherwise, there were no or_conditions and the or_conditions
// should remain ""
if ($or_conditions_trigger == 1)
{
// there was a set of or_conditions so add a front and back to the query
$or_conditions = " AND (" . $or_conditions . ")";
}
else
{
// do nothing and let the or_conditions variable remain blank
}
// echo "-----
";
// echo $or_conditions;
?>
if(strlen($flavour_text) > 275) { echo substr($flavour_text, 0, 275); ?> ... (More) } else { echo $flavour_text; } ?>
// get all of the tags for this content piece $result_content_tags = mysqli_query($conn, "SELECT tags.*, tags_to_content.* FROM tags, tags_to_content WHERE tags.tag_id = tags_to_content.tag_id AND tags_to_content.content_id = " . $content_id . " ORDER BY tags.output_order"); while ($query_data_content_tags = mysqli_fetch_assoc($result_content_tags)) { // get the tag ID $tag_id = $query_data_content_tags["tag_id"]; // pull the id and name for the tag $result_tag_info = mysqli_query($conn, "SELECT * FROM tags WHERE tag_id = " . $tag_id); while ($query_data_tag_info = mysqli_fetch_assoc($result_tag_info)) { ?> echo $query_data_tag_info["tag_name"]; ?> } } ?>