开发者

interruption while running php file

开发者 https://www.devze.com 2022-12-22 23:49 出处:网络
this is my code in php bt its not working problerly as required..the output is not according to this..

this is my code in php bt its not working problerly as required..the output is not according to this.. i m trying to run this in wamp server.

<html>
<head>
    <title>Binary Search</title>
    <style type="text/css">
        h1 {color: blue}
    </style>
</head>
<body>
<h1 align="center">Computer guess number by using binary search</h1>
<form method="GET">
<?
if (empty($flag_num))
{
    $flag_num = -1;
}
if ($flag_num==-1)
{
if (empty($max_num)) $max_num = -1;
if (empty($min_num)) $min_num = -1;
$flag_num = 1;
print <<<Here
<input type="hidden" name="flag_num" value="$flag_num">
<input type="hidden" name="max_num" value="$max_num">
<input type="hidden" name="min_num" value="$min_num">
Input your hidden number: <input type="text" name="hid_num" value="$hid_num"> (1-99)
<br>
<input type="submit" value="Now let's computer guess">
Here;
}
else 
{
if ($max_num==-1 && $min_num==-1)
{
    $max_num = 100;
    $min_num = 0;
    $result_num = $hid_num;
}
else 
{
    if ($comparision == "bigger")
    {
        $min_num = $guess_num;  
    }
    else if ($comparision == "smaller")
    {
        $max_num = $guess_num;  
    }
}
$guess_num = ($max_num + $min_num)/2;
setType($guess_num,"integer");
print "Computer guess <h3> $guess_num </h3>";
if ($guess_num == $result_num)
{
    $flag_num = -1;
}
if ($flag_num == -1)
{
    print <<<Here
<input type="hidden" name="flag_num" value="$flag_num">
<h1> Congratulation, Computer win </h1>
<input type="submit" value="Next>>>" >
Here;
}
else 
{
    print <<<Here
<input type="hidden" name="flag_num" value="$flag_num">
<input type="hidden" name="max_num" value="$max_num">
<input type="hidden" name="min_num" value="$min_num">
<input type="hidden" name="guess_num" value="$guess_num">
<input type="hidden" name="result_num" value="$result_num">
<br>
Your intruction: <开发者_开发问答;input type="radio" name="comparision" value="bigger"> Bigger
                 <input type="radio" name="comparision" value="smaller"> Smaller
<br>
<input type="submit" value="Submit">
Here;
}
}
?>
</form>
</body>
</html>


You need to use $_GET['flag_num'] to get the query parameter, rather than $flag_num. The script isn't doing anything because none of the variables have any value. Similarly, $_GET['max_num'], $_GET['min_num'], $_GET['hid_num'].

0

精彩评论

暂无评论...
验证码 换一张
取 消