-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery_creator.php
More file actions
32 lines (27 loc) · 875 Bytes
/
query_creator.php
File metadata and controls
32 lines (27 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
foreach ($names as $index => $name) {
$tmp = explode("~", $name);
$table = $tmp[0];
$field = $tmp[1];
$value = $tmp[2];
$strSQL = "SELECT count(0) as value FROM $table WHERE `$field` = '$value';";
$result = execute($strSQL);
echo "<div id='indvCount'>";
foreach ($result as $row) {
echo "<div><b>Where Clause Field: \"$field\"</b> -> Selected Value: \"$value\"" .
"<br/>Total Records found: N = " . $row["value"] . "</div>";
}
echo "</div>";
if ($index == 0) {
$queryFrom .= $table;
} else if ($prevTable == $table) {
$queryWhere.= " AND ";
} else if ($prevTable != $table) {
$queryFrom .= " INNER JOIN $table ON $prevTable.$joinField = $table.$joinField";
$queryWhere.= " AND ";
}
$queryWhere.= "$table.`$field` = '$value' ";
$prevTable = $table;
}
$joinQuery = "SELECT $prevTable.$chooseField FROM $queryFrom WHERE $queryWhere";
?>