我想知道我的代码中是否存在问题。在代码括号中,尽管有相同数量的开括号和闭括号,但最终结束的大括号与最高大括号不匹配。
<?php
include_once 'dbconnect.php';
if(isset($_POST['page']))
{
$page = $_POST['page'];
$cur_page = $page;
$page -= 1;
$per_page=10;
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;
if(!empty($_POST['run']))
{
$value1=$_POST['run'];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.run like '%$value1%' ";
}
else if(!empty($_POST['project']))
{
$value1=$_POST['project'];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.project like '%$value1%'";
}
else if(!empty($_POST['sample']))
{
$value1=$_POST['sample'];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.sample_id like '%$value1%'";
}
else if(!empty($_POST['bases']))
{
$value1=$_POST['bases'];
$values=$_POST['select1'];
switch($values)
{
case "greaterthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) > '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) asc";
break;
case "greaterthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) >= '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) asc ";
break;
case "lessthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) < '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) desc ";
break;
case "lessthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) <= '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) desc ";
break;
case "equal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) = '$value1' ";
break;
}
}
else if(!empty($_POST['reads']))
{
$value5=$_POST['reads'];
$values2=$_POST['select2'];
switch($values2)
{
case "greaterthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) > '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc";
break;
case "greaterthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) >= '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc";
break;
case "lessthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) < '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) desc";
break;
case "lessthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) <= '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) desc";
break;
case "equal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) = '$value5' ";
break;
}
}
// multiple combination search code starts
if(!empty($_POST['run']) && !empty($_POST['project']))
{
$valueR=$_POST['run'];
$valueP=$_POST['project'];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.run like '%$valueR%' AND a.project like '%$valueP%'";
}
else if(!empty($_POST['project']) && !empty($_POST['sample']))
{
$valueP=$_POST['project'];
$valueS=$_POST['sample'];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.project like '%$valueP%' AND a.sample_id like '%$valueS%'";
}
else if(!empty($_POST['sample']) && !empty($_POST['run']))
{
$valueS=$_POST['sample'];
$valueR=$_POST['run'];
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.sample_id like '%$valueS%' AND a.run like '%$valueR%'";
}
else if(!empty($_POST['run']) && !empty($_POST['bases']))
{
$valueR=$_POST['run'];
$value123=$_POST['bases'];
$valuesS1=$_POST['select1'];
switch($valuesS1)
{
case "greaterthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) > '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) ASC ";
break;
case "greaterthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) >= '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) ASC ";
break;
case "lessthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) < '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) DESC ";
break;
case "lessthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) <= '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) DESC";
break;
case "equal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) = '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0))";
break;
}
}
else if(!empty($_POST['run']) && !empty($_POST['reads']))
{
$valueR=$_POST['run'];
$value51=$_POST['reads'];
$valuesS2=$_POST['select2'];
switch($valuesS2)
{
case "greaterthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) > '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc ";
break;
case "greaterthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) >= '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) ASC ";
break;
case "lessthan":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) < '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) DESC ";
break;
case "lessthanorequal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) <= '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) DESC";
break;
case "equal":
$sql="SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) = '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) ";
break;
}
}
} ?>
我想知道我的代码中是否存在问题。在代码括号中,尽管有相同数量的开括号和闭括号,但最终结束的括号与顶部括号不匹配。
答案 0 :(得分:0)
如果您一直遵循PSR-1/PSR-2代码格式,那么您会看到所有大括号都正确匹配,正如@Hannan在您的帖子评论中所说的那样。下面是使用PHPStorm设置为PSR-1 / PSR-2格式缩进的代码。 (注意:我不是说你必须使用PSR-1 / PSR-2,只是说你可以)
<?php
include_once 'dbconnect.php';
if (isset($_POST['page'])) {
$page = $_POST['page'];
$cur_page = $page;
$page -= 1;
$per_page = 10;
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $page * $per_page;
if (!empty($_POST['run'])) {
$value1 = $_POST['run'];
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.run like '%$value1%' ";
} else {
if (!empty($_POST['project'])) {
$value1 = $_POST['project'];
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.project like '%$value1%'";
} else {
if (!empty($_POST['sample'])) {
$value1 = $_POST['sample'];
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.sample_id like '%$value1%'";
} else {
if (!empty($_POST['bases'])) {
$value1 = $_POST['bases'];
$values = $_POST['select1'];
switch ($values) {
case "greaterthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) > '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) asc";
break;
case "greaterthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) >= '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) asc ";
break;
case "lessthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) < '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) desc ";
break;
case "lessthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) <= '$value1' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) desc ";
break;
case "equal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) = '$value1' ";
break;
}
} else {
if (!empty($_POST['reads'])) {
$value5 = $_POST['reads'];
$values2 = $_POST['select2'];
switch ($values2) {
case "greaterthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) > '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc";
break;
case "greaterthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) >= '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc";
break;
case "lessthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) < '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) desc";
break;
case "lessthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) <= '$value5' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) desc";
break;
case "equal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) = '$value5' ";
break;
}
}
}
}
}
}
// multiple combination search code starts
if (!empty($_POST['run']) && !empty($_POST['project'])) {
$valueR = $_POST['run'];
$valueP = $_POST['project'];
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.run like '%$valueR%' AND a.project like '%$valueP%'";
} else {
if (!empty($_POST['project']) && !empty($_POST['sample'])) {
$valueP = $_POST['project'];
$valueS = $_POST['sample'];
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.project like '%$valueP%' AND a.sample_id like '%$valueS%'";
} else {
if (!empty($_POST['sample']) && !empty($_POST['run'])) {
$valueS = $_POST['sample'];
$valueR = $_POST['run'];
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE a.sample_id like '%$valueS%' AND a.run like '%$valueR%'";
} else {
if (!empty($_POST['run']) && !empty($_POST['bases'])) {
$valueR = $_POST['run'];
$value123 = $_POST['bases'];
$valuesS1 = $_POST['select1'];
switch ($valuesS1) {
case "greaterthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) > '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) ASC ";
break;
case "greaterthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) >= '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) ASC ";
break;
case "lessthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) < '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) DESC ";
break;
case "lessthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) <= '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0)) DESC";
break;
case "equal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_bases + IFNULL(c.raw_bases2,0)) = '$value123' AND a.run LIKE '%$valueR%' ORDER by (b.raw_bases + IFNULL(c.raw_bases2,0))";
break;
}
} else {
if (!empty($_POST['run']) && !empty($_POST['reads'])) {
$valueR = $_POST['run'];
$value51 = $_POST['reads'];
$valuesS2 = $_POST['select2'];
switch ($valuesS2) {
case "greaterthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) > '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) asc ";
break;
case "greaterthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) >= '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) ASC ";
break;
case "lessthan":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) < '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) DESC ";
break;
case "lessthanorequal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) <= '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) DESC";
break;
case "equal":
$sql = "SELECT a.run, a.lane, a.project, a.sample_id,a.end_type,b.raw_bases, b.raw_reads, c.raw_bases2, c.raw_reads2 FROM cp_sampleSheet a left JOIN cp_samp_R1 b ON a.sample_id = b.sample_id left JOIN cp_samp_R2 c ON a.sample_id =c.sample_id WHERE (b.raw_reads + IFNULL(c.raw_reads2,0)) = '$value51' AND a.run LIKE '%$valueR%' ORDER by (b.raw_reads + IFNULL(c.raw_reads2,0)) ";
break;
}
}
}
}
}
}
}
?>
我建议为那些结束括号添加注释,以便您能够看到哪个括号关闭哪个语句。它看起来像是:
} // switch $valuesS2
} // if $_POST run & reads not empty
} // if POST run & bases not empty
} // if POST sample && run not empty
} // if POST project && sample not empty
} // if POST run && project not empty
} // POST page isset
?>
此外,如果您认为自己错过了;:[]{}(),.
中的一个,那么您的代码将在执行时抛出致命错误。它看起来像这样(删除了一个;从工作代码,样式xdebug)这当然只有当它们是代码的一部分时,所以当它们出现在一个字符串中而一个丢失时,不会有致命的错误。