使用GET方法运行php脚本,并查询数据库中的结果

使用GET方法运行php脚本,并查询数据库中的结果,php,html,sql-server,Php,Html,Sql Server,我很抱歉向其他人提出了一个非常类似的问题,但我不能完全理解这一点。基本上,我需要显示一个html页面,我已经用一个从PHP脚本获取信息的表单设置了这个页面。到目前为止,在HTML中,我已经 <!-- FORM START --> <form action="checkscript.php" method="get"> <!-- Input text box with styling over image --> <

我很抱歉向其他人提出了一个非常类似的问题,但我不能完全理解这一点。基本上,我需要显示一个html页面,我已经用一个从PHP脚本获取信息的表单设置了这个页面。到目前为止,在HTML中,我已经

<!-- FORM START -->
    <form action="checkscript.php" method="get">
        <!-- Input text box with styling over image -->
        <input type="text" style="position:relative; left:8px; top:-75px; font-family:arial; font-size:32px; background-color:transparent; height:44px; width:268px; border:none; font-weight:bold; text-transform:uppercase; text-align:center;" placeholder="TICKET ID" maxlength="7" name="ticketId" />
        <!-- Button with styling to execute PHP script -->
        <button type="button" style="position:relative; top:-45px; width:300px; height:30px; font-family:arial; font-size:16px; font-weight:bold;">Find Details</button> 
    </form>
(已完成或未完成的单词将出现在“StageOne”、“StageTo”和“StageThree”列下的行中)

要在与“ticketId”相同的行中查找结果,以及如何将检索到的信息显示为HTML,例如,如果$stage变量=“StageOne”,特定元素将显示在HTML中

对不起,我知道这一定很简单,但我可以在这里得到一些帮助。任何帮助都将不胜感激,特别是如果你能把它做得非常详细的话

谢谢

Ed

请尝试以下代码:

<?php
$db = mssql_connect("dbsrv02", "requsr", "");
mssql_select_db("ticketDb",$db);
$result = mssql_query("SELECT ticketId, StageOne, StageTwo, StageThree",$db);
$num = mssql_num_rows($result);
$regPlate = $_GET['ticketId'];
$i = 1;

// creating table header
echo "<table>";
echo "<tr> 
    <td> num </td> 
    <td> stage1 </td> 
    <td> stage2 </td> 
    <td> stage3 </td> 
    <td> stage </td> 
    </tr>";

while ($myrow = mssql_fetch_array($result))  {
    if ($myrow["StageOne"] = "Completed" and $myrow["StageTwo"] = "Uncomplete" and $myrow["StageThree"] = "Uncomplete" {
       $stage = "StageOne"
    }
    // fecthing row
    echo "<tr>";
    echo "<td> " . $num . "</td>";
    echo "<td> " . $myrow["StageOne"]  . "</td>";
    echo "<td> " . $myrow["StageTwo"]  . "</td>";
    echo "<td> " . $myrow["StageThree"]  . "</td>";
    echo "<td> " . $stage   . "</td>";
    echo "</tr>";
}
$i++;
} 
// table tag closing
echo "</table>";

if ($num < 1){ // if there nothing
echo "Sorry, nothing there to see!";
}else{
echo "There are " . $num "s data";
}
?>

如果..你是认真的吗?你的意思是说,
do..while
method?@史密斯先生不确定。你能解释一下吗?我对那件事不太了解。我只知道如果命令是因为其他语言
if()do{}
不是。您可能想看看if在PHP中是如何使用的:@Mr.Smith Oh ok,抱歉。你认为你能纠正代码吗,或者更好,帮我填空?谢谢你的链接@codejak!我已经复制了,我按下了按钮,但是什么都没发生。。。我觉得我错过了显而易见的东西,因为我知道很多HTML!尝试将您的按钮更改为URL更改为,并且正文为空,没有页面源代码…尝试打开您的php my admin并填写您的sql代码“SELECT ticketId,StageOne,stageTo,StageThree”不要使用phpmyadmin,它的MSSQL
if ($myrow["StageOne"] = "Completed" and $myrow["StageTwo"] = "Uncomplete" and $myrow["StageThree"] = "Uncomplete" {
    $stage = "StageOne"
}
<?php
$db = mssql_connect("dbsrv02", "requsr", "");
mssql_select_db("ticketDb",$db);
$result = mssql_query("SELECT ticketId, StageOne, StageTwo, StageThree",$db);
$num = mssql_num_rows($result);
$regPlate = $_GET['ticketId'];
$i = 1;

// creating table header
echo "<table>";
echo "<tr> 
    <td> num </td> 
    <td> stage1 </td> 
    <td> stage2 </td> 
    <td> stage3 </td> 
    <td> stage </td> 
    </tr>";

while ($myrow = mssql_fetch_array($result))  {
    if ($myrow["StageOne"] = "Completed" and $myrow["StageTwo"] = "Uncomplete" and $myrow["StageThree"] = "Uncomplete" {
       $stage = "StageOne"
    }
    // fecthing row
    echo "<tr>";
    echo "<td> " . $num . "</td>";
    echo "<td> " . $myrow["StageOne"]  . "</td>";
    echo "<td> " . $myrow["StageTwo"]  . "</td>";
    echo "<td> " . $myrow["StageThree"]  . "</td>";
    echo "<td> " . $stage   . "</td>";
    echo "</tr>";
}
$i++;
} 
// table tag closing
echo "</table>";

if ($num < 1){ // if there nothing
echo "Sorry, nothing there to see!";
}else{
echo "There are " . $num "s data";
}
?>