OK みんな私はあなたの助けが必要です もう一度お願いできますか??
フィルター条件のセットとして、ドロップダウン オプションのリストがあります。
それぞれが選択されると、クエリ文字列に追加され、選択に等号 (=) が追加されるため、Large を選択すると、クエリは size = large になります。
影響を受けると呼ばれる選択が 1 つありますが、ユーザーが影響を受けるを選択すると、クエリに = を追加したくありません。影響を受けるデータベース列のどこでも検索できるように、「クリック」のように影響を受ける場所にしたいのです。
= to のままである場合、影響を受けるシステムが 1 つだけあり、レッスンに対して正確に = to に保存されている選択のみが戻されます。
SELECT p.project_id
, p.project_name
, p.department
, p.size
, p.programme
, l.captured_by
, l.stage
, l.type
, l.impacted
, l.depts_inv
, l.lesson_title
, l.lesson_learned
, l.lesson_added
FROM ll_project p
JOIN ll_lessons l
ON l.project_id = p.project_id
AND l.impacted = 'Click';
これは現在コードを取り込む方法ですが、誰かが影響を受けるフィルターに対して選択を行った場合、その前に = を追加せずにクエリに「含む」または「好き」を追加したいのです。
これが完全なコードです。
<?php
//Set all Variables pulled from POST of previous page
$pid = $_POST['project_id'] ;
$psize = $_POST['projectSize'] ;
$pdepts = $_POST['depts'] ;
$lstage = $_POST['stage'] ;
$ltype = $_POST['type'] ;
$impacted = $_POST['impacted'] ;
//Create Column Variable to hold Values in an array linked to the database columns
$columns = array('project_id'=>'ll_project.project_id','projectSize'=>'size','depts'=>'department','stage'=>'ll_lessons.stage','type'=>'ll_lessons.type','impacted'=>'ll_lessons.impacted');
$sqlString = null;
//Check all POSTED data is pulling through - Should be 6
//echo "Total Number Of Captured Post Variables is:";
//echo count($_POST);
$number = 0;
$queryStr = "";
$preStr = array();
//For Every POSTED Value Set the Name as Key and the Value against Each
foreach ($_POST as $key => $val ) {
if (!empty($_POST[$key])){
if(!is_array($_POST[$key]))
//Escape the VALUE by surrounding it with Quotes as it is a string the value would not be picked up on the query.
$currentStr = $columns[$key]." = '".mysql_real_escape_string($val)."'";
else
$currentStr = $columns[$key]." IN (".implode(',',$_POST[$key]).")";
$preStr[] = $currentStr;
}
}
//set the Query String that i want to return from the Database and set the join on the BSKYB NUMBERS on both Tables
$queryStr = "SELECT ll_project.project_id, ll_project.project_name, ll_project.department, ll_project.size, ll_project.programme, ll_lessons.captured_by, ll_lessons.stage, ll_lessons.type, ll_lessons.impacted, ll_lessons.depts_inv, ll_lessons.lesson_title, ll_lessons.lesson_learned, ll_lessons.lesson_added FROM ll_project INNER JOIN ll_lessons ON ll_project.project_id = ll_lessons.project_id WHERE ".implode(' AND ',$preStr);