<form method="post" action="newrs.php" target="_blank" enctype="multipart/form-data" >
<table>
<tr>
<td><font style="font-size:20px">Snp Id:</font></td>
<td><input type="text" name="isnp_id" id="idsnp_id" placeholder="Ex:SCcLG07_1001342" size=20 style="font-size:18px"></td>
</tr>
<tr>
<td><font style="font-size:20px">Gene Id:</font></td>
<td><input type="text" name="igene" id="idgene" placeholder="Ex:C.cajan_17400" size=20 style="font-size:18px"></td>
</tr>
<tr>
<td><font style="font-size:20px">Chromosome:</font></td>
<td><input type="text" name="ichr" id="idchr" placeholder="Ex:CcLG07" size=20 style="font-size:18px"></td>
<td> position from </td>
<td><input type="text" name="posstart" id="idposstart" placeholder="Ex: 1" size="20"> to <input type="text" name="posend" id="idposend" placeholder="Ex:100" size="20">
</td>
</tr>
<tr>
<td><font style="font-size:20px">Effect:</font></td> <td><input type="text" name="ieff" id="ideff" placeholder="Ex:Low, High, Moderate" size=20 style="font-size:18px"></td>
</tr>
</table>
<br/>
<span><font style="font-size:22px;color:green">Options:</font></span><br/>
<table>
<tr>
<td><input type="checkbox" name="cb" value="cb_class" /></td><td><font style="font-size:20px">Classification:</font></td>
<td><select style="font-size:18px" name="sclass" >
<option value="all" selected="selected">Select</option>
<option value="intergenic">Intergenic</option>
<option value="intronic">Intronic</option>
<option value="non_synonymous_coding">Non Synonymous Coding</option>
<option value="synonymous_coding">Synonymous Coding</option>
</select> </td>
</tr>
<tr>
<td><input type="checkbox" name="cb" value="cb_vtype" /></td><td><font style="font-size:20px">Varation Type:</font></td>
<td><select style="font-size:18px" name="svtype" >
<option value="all" selected="selected">Select</option>
<option value="snp">Snp</option>
<option value="insertion">Insertion</option>
<option value="deletion">Deletion</option>
</select> </td>
</tr>
<tr>
<td><input type="checkbox" name="cb" value="cb_fc" /></td><td><font style="font-size:20px">Functional Class:</font></td>
<td><select style="font-size:18px" name="sfunclass" >
<option value="all" selected="selected">Select</option>
<option value="missense">Missense</option>
<option value="nonsense">Nonsense</option>
<option value="silent">silent</option>
</select>
</td>
</tr>
<tr>
<td></td><td></td>
<td><input type="reset" name ="reset" value="Reset" style="font-size:18px">
<input type="submit" name="submit" value="Search" style="font-size:18px"> </td>
</tr>
</table>
</form>
php code starts here:
<?php
include_once 'connect.php';
if(isset($_POST['submit']))
{
$selected_cb=$_POST['cb'];
if(($gene=$_POST['igene']) && ($selected_cb=='cb_class') && ($selected_cb=='cb_vtype'))
{
$selectc=$_POST['sclass'];
if($selectc=='intergenic')
{
$selectv=$_POST['svtype'];
switch($selectv)
{
case "snp":
$sql="select snp_eff.*,variations_categorised.variation_type from snp_eff inner join variations_categorised on snp_eff.snp_id = variations_categorised.snp_id where snp_eff.classification ='INTERGENIC' AND snp_eff.transcript like '%$gene%' AND variations_categorised.variation_type='SNP' LIMIT 1000";
break;
case "insertion":
$sql="select snp_eff.*,variations_categorised.variation_type from snp_eff inner join variations_categorised on snp_eff.snp_id = variations_categorised.snp_id where snp_eff.classification ='INTRONIC' AND snp_eff.transcript like '%$gene%' AND variations_categorised.variation_type='INSERTION' LIMIT 1000";
break;
case "deletion":
$sql="select snp_eff.*,variations_categorised.variation_type from snp_eff inner join variations_categorised on snp_eff.snp_id = variations_categorised.snp_id where snp_eff.classification ='NON_SYNONYMOUS_CODING' AND snp_eff.transcript like '%$gene%' AND variations_categorised.variation_type='DELETION' LIMIT 1000";
break;
}
}
}
}
$counter=0;
if($result = pg_query($link, $sql)) {
if(pg_numrows($result) > 0) {
?>
<table id="t01" >
<tr >
<th>sno</th>
<th>chr</th>
<th>pos</th>
<th>snp_id</th>
<th>ref_base</th>
<th>alt_base</th>
<th>classification</th>
<th>effect</th>
<th>functional class</th>
<th>variation type</th>
<th>Gene ID</th>
</tr>
<?php
while($row = pg_fetch_array($result)){
?>
<tr>
<td><?php echo ++$counter ;?> </td>
<td><?php echo $row['chr'] ;?> </td>
<td><?php echo $row['position'] ;?> </td>
<td><?php echo $row['snp_id'] ;?> </td>
<td><?php echo $row['ref'] ;?> </td>
<td><?php echo $row['alt'] ;?> </td>
<td><?php echo $row['classification'] ;?> </td>
<td><?php echo $row['effect'] ;?> </td>
<td><?php echo $row['functional_class'] ;?> </td>
<td><?php echo $row['variation_type'] ;?> </td>
<td><?php echo $row['transcript'] ;?> </td>
</tr>
<?php
}
}
else{
echo " No records matching your query were found.";
}
}
?>
</table>
我在使用三种组合搜索记录时没有得到任何结果。在Apache日志它显示错误:我无法在PHP中执行我的代码
未定义的变量:SQL
我想不出什么我错过了这个代码的东西。
您能显示connect.php文件吗? –
你得到那个错误是因为'$ sql'并不总是被设置。它只在执行'switch()'的时候被设置,并且如果页面从不提交,它将永远不会被设置。 – Daniel
'if(($ gene = $ _ POST ['igene'])&&($ selected_cb =='cb_class')&&($ selected_cb =='cb_vtype'))'< - 确定您想使用'=='而不是你的IF语句中的'='。 – Twinfriends