我很抱歉向其他人提出了一个非常相似的问题,但我无法完全理解这一点。最重要的是,我需要显示一个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>
在查询数据库的checkscript.php中,我有
<?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;
if ($myrow = mssql_fetch_array($result)) do {
<<< what goes here? >>>
}
if ($num > $i) printf(",");
$i++;
} while ($myrow = mssql_fetch_array($result));
else {
echo "Sorry, nothing there to see!";
}
?>
现在,我需要的是知道在上面写着<lt<这里是什么?>>。我需要使用类似的东西
if ($myrow["StageOne"] = "Completed" and $myrow["StageTwo"] = "Uncomplete" and $myrow["StageThree"] = "Uncomplete" {
$stage = "StageOne"
}
(单词Completed或Uncomplete将出现在"StageOne"、"StageTwo"answers"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";
}
?>