<?php include_once "../../database/dbConnection.php"; $connection = new DatabaseConnection(); $queryId = $_GET['queryId']; // Remove queryId from $_GET unset($_GET['queryId']); //Create data array $data = array('data' => array()); //Connect to the DB $connection->openConn(); //Execute query $sql = "SELECT QUERY FROM `queries` WHERE QUERY_ID = '{$queryId}'"; $result = $connection->runQuery($sql); //Get SQL Query if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } else { $sql = mysql_fetch_row($result)[0]; } //Get attributes to be replaced on SQL query $attributeAdded = false; foreach ($_GET as $key => $attribute) { if (strpos($sql, $key) === false) { //If the attribute is not found on the query, append it to the end of the SQL $sql .= " `" . $key . "` = '" . $attribute . "' AND"; $attributeAdded = true; } else { //Replace the string variable with the actual attribute $tempSql = $sql;