Location: PHPKode > scripts > phpRetrieve > phpRetrieve/getMySQL.php
<?php

	$myQuery = "";
	
	if(isset($_SESSION['session_Query'])){
		$myQuery = $_SESSION['session_Query'];
	}
	
	if($myQuery == ""){
			//Build Query

				$mySelect = "";
				$myWhere = "";
				$i = 0;
				if($tbl != ""){
					while ($array = mysql_fetch_array($fld_result)) {
						$i++;
						$fld = $array['Field'];
						$tpe = $array['Type'];
						$selectField = ""; if(isset($arr[$fld]['Select'])){ $selectField = $arr[$fld]['Select']; }
						$conditionField = ""; if(isset($arr[$fld]['Condition'])){ $conditionField = $arr[$fld]['Condition']; }
						$val1Field = ""; if(isset($arr[$fld]['Val1'])){ $val1Field = addslashes($arr[$fld]['Val1']); }
						$val2Field = ""; if(isset($arr[$fld]['Val2'])){ $val2Field = addslashes($arr[$fld]['Val2']); }
						if($selectField == "yes"){
							if($mySelect == ""){ $mySelect = $fld; }
							else { $mySelect .= ", ".$fld; }
						}
						$wh = "";
						if($conditionField=="eq" && $val1Field !=""){ $wh = $fld." = '$val1Field'"; }
						if($conditionField=="gt" && $val1Field !=""){ $wh = $fld." > '$val1Field'"; }
						if($conditionField=="lt" && $val1Field !=""){ $wh = $fld." < '$val1Field'"; }						
						if($conditionField=="ge" && $val1Field !=""){ $wh = $fld." >= '$val1Field'"; }
						if($conditionField=="le" && $val1Field !=""){ $wh = $fld." <= '$val1Field'"; }
						if($conditionField=="lk" && $val1Field !=""){ $wh = $fld." LIKE '$val1Field'"; }
						if($conditionField=="bt" && $val1Field !=""){ $wh = $fld." BETWEEN '$val1Field' AND '$val2Field'"; }
						if($wh != ""){
							if($myWhere == ""){ $myWhere = "WHERE $wh"; }
							else{ $myWhere .= " AND $wh"; }
						}
					}
					if($mySelect == "" ){ $mySelect = "*"; }
					$myQuery = "SELECT $mySelect FROM $tbl $myWhere ";
				}

	}


?>
Return current item: phpRetrieve