我有输入表格:
<form style="font-size: 10pt; font-family: 'Courier New'; color:black;font-weight:600;margin-left:15px;line-height:25px" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="radio" id="a" name="search" value="EntryId" checked>EntryId <font color="blue">(get Vocab information)</font>
<br />
<input type="radio" id="b" name="search" value="EntryId1">EntryId <font color="blue">(get disease name, protein name)</font>
<br />
<input type="radio" id="c" name="search" value="UniprotId">UniprotId <font color="blue">(get Gene name, Dna Seq)</font>
<br />
<input type="radio" id="d" name="search" value="Genename">Genename <font color="blue">(get Gene information)</font>
<br />
<input type="radio" id="e" name="search" value="EntryId3">EntryId <font color="blue">(get HTML, PubMed information)</font>
<br /><br /><br />
<input style="height:30px; width: 300px; border:black 1px solid" type="text" name="Search" >
<input style="height:30px" type="submit" value="Go">
</form>
在这种形式中,我使用六个单选按钮,每个按钮代表一个存储在MySQL中的存储过程。如果我选择一个单选按钮并在文本框中输入一个值(这将是我所选程序的参数),我想要输出该程序。
PHP代码:
<?php
$id='';
$query='';
if (isset($_POST['Search']))
{
$id=$_POST['Search'];
}
echo "<table>";
//connect to database
$connection = mysqli_connect("localhost", "root", "", "mohammad_prostatecancer");
//run the store proc
if (isset($_POST['EntryId1']))
{
$query= "call DiseaseVocab(".'"'.$id.'")';
}
if (isset($_POST['EntryId2']))
{
$query= "call DiseaseProtein(".'"'.$id.'")';
}
if (isset($_POST['UniprotId']))
{
$query= "call getGene(".'"'.$id.'")';
}
if (isset($_POST['Genename']))
{
$query= "call Getname(".'"'.$id.'")';
}
if (isset($_POST['EntryId3']))
{
$query= "call Getdata(".'"'.$id.'")';
}
$result = mysqli_query($connection, $query) or die("Query fail: " . mysqli_error());
//loop the result set
echo "<tbody>";
// point to the beginning of the array
$check = mysqli_data_seek($result, 0);
?>
<tr>
<td><b>EntryId</b></td>
<td><b>Vocabid</b></td>
<td><b>VocabSourceName</b></td>
</tr>
<?php
while ($rownew = mysqli_fetch_assoc($result)) {
echo "<tr>";
foreach($rownew as $k => $v)
{
echo "<td>".$v."</td>";
}
echo "</tr>"."<br>";
}
echo "</tbody></table>";
?>
我没有得到任何结果。我收到这些警告:
Warning: mysqli_query(): Empty query
Warning: mysqli_error() expects exactly 1 parameter, 0 given
答案 0 :(得分:0)
您需要错误中的连接,这样做,然后您就可以看到错误。
mysqli_error($connection)
答案 1 :(得分:0)
查询为空,因为您正在检查
`if (isset($_POST['EntryId1']))` instead of `if (isset($_POST['search']) && $_POST['search']=='EntryId1')`
and switch case would be b`enter code here`etter in this scenario.