したがって、基本的には、html とインラインで php を使用してページを作成しています。ドロップダウンから新しいオプションを選択するか、テキスト ボックスに新しい値を入力すると、それを変更する必要があります。PHPですべてのHTMLをエコーしていたときにこれが機能していました(私が知っている愚かな間違いです)が、それをクリーンアップしようとしたので、機能しなくなったようです。また、すべてのデータベース接続が正常に機能しているため、何が起こっているのかわかりません。以下にリストされている完全なコード。助けてくれてありがとう。私はこれに少し慣れていないことを覚えておいてください。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Megapixel Calculator</title>
<meta name="Megapixel Calculator" content="">
<meta name="Matthew Stair" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body style="background:#99CCFF;overflow:hidden;">
<?php
$host = "localhost";
$username = "root";
$pass = "";
$database = "database_camcalc";
$conn = mysql_connect($host, $username, $pass) or die (mysql_error());
mysql_select_db($database, $conn);
$query = "SELECT camera FROM camlist";
$result = mysql_query($query) or die (mysql_error());
if (isset($_POST['cameraDD']))
{
$camSelect = $_POST['cameraDD'];
}else{
$camSelect = 'SNV-5200';
}
$horiQuery = mysql_query("SELECT hori FROM camlist WHERE camera = '$camSelect'");
if (!$horiQuery) {
die("Failed: " . mysql_error());
}
$hori = mysql_fetch_row($horiQuery);
$sensorSize = mysql_query("SELECT sensor_size FROM camlist WHERE camera = '$camSelect'");
if (!$sensorSize) {
die("Failed: " . mysql_error());
}
$sensorQuery = mysql_query("SELECT camlist.width FROM camlist WHERE camlist.camera = '$camSelect'");
$sensorRow = mysql_fetch_array($sensorQuery);
$sensorWidth = floatval($sensorRow['width']);
if(isset($_POST['horizontalFOV'])){
if($_POST['horizontalFOV'] != 0){
$horiFOV = $_POST['horizontalFOV'];
}else{
$horiFOV = 20;
}
}else{
$horiFOV = 20;
}
if(isset($_POST['distToObj'])){
if($_POST['distToObj'] != 0){
$distObj = $_POST['distToObj'];
}else{
$distObj = 35;
}
}else{
$distObj = 35;
}
$lensCalc = ($distObj / $horiFOV) * $sensorWidth;
$lensCalcFix = number_format($lensCalc);
$ppfCalc = $hori[0] / $horiFOV;
?>
<div style="width:1000px; margin:auto;">
<div style="width:50%;float:left;">
<div style="float:left; width:100%;">
<?php
print("Select Camera: <select name='cameraDD' value='$camSelect' onchange='this.form.submit()'>");
while($row = mysql_fetch_assoc($result)) {
if($row['camera'] == $camSelect)
print("\r\n<option selected='selected' value='{$row['camera']}'>{$row['camera']}</option>");
else
print("\r\n<option value='{$row['camera']}'>{$row['camera']}</option>");
}
?>
</select>
</div>
<div style="float:left;width:50%;">
Lens Focal Length: <?php print("$lensCalcFix"); ?> MM
</div>
<div style="float:left;width:50%;">
<?php
print("Horizontal Field of View: <input style='width:50px;' type='text' name='horizontalFOV' value='$horiFOV' onchange='this.form.submit()'>");
?>
</div>
<img style="width:100%" src="/images/example.gif" alt="Example of horizontal field of view and distance to object">
<div>
<?php
print("Distance to Object: <input style='width:50px;' type='text' name='distToObj' value='$distObj' onchange='this.form.submit()'> Feet");
?>
</div>
</div>
<div style="width:40%;float:left;margin-left:10px;">
<div>
<?php
echo 'Pixels per Foot: ',
round($ppfCalc),
' PPF';
?>
</div
<div>
<?php
if ($ppfCalc < 19){
echo "<p style ='font-weight:bold;'>Level of detail: Too Low</p>";
echo "<img src='images/noimg.gif' alt='Pixel Per Foot Too Low'>";
}elseif ($ppfCalc >= 19 and $ppfCalc <=39){
echo "<p style ='font-weight:bold;'>Level of detail: Observation</p>";
echo "<img src='images/20ppf.gif' alt='Observation Level'>";
}elseif ($ppfCalc >=40 and $ppfCalc <=59){
echo "<p style ='font-weight:bold;'>Level of detail: Forensic Review</p>";
echo "<img src='images/40ppf.gif' alt='Forensic Review Level'>";
}elseif ($ppfCalc >=60 and $ppfCalc <=79){
echo "<p style ='font-weight:bold;'>Level of detail: Identification</p>";
echo "<img src='images/75ppf.gif' alt='Identification Level'>";
}elseif ($ppfCalc >=80){
echo "<p style ='font-weight:bold;'>Level of detail: Fine</p>";
echo "<img src='images/100ppf.gif' alt='Fine Level'>";
}
?>
<div style="width:300px;">
<p style="text-decoration:underline;font-weight:bold;">Observation (General Security) = 20 PPF</p>
<p> Allows for recognition of male/female, color of clothes, approximate height, color of skin, etc...</p>
<p style="text-decoration:underline;font-weight:bold;">Forensic Review (forensic detail)= 40 PPF</p>
<p>Allows for basic identification of forensic details</p>
<p style="text-decoration:underline;font-weight:bold;">Identification (high detail)= 60 PPF</p>
<p>Allows for facial recognition, point-of-sale tracking, etc...</p>
<p style="text-decoration:underline;font-weight:bold;">Fine = 80 PPF</p>
<p>Allows for detailed facial recognition such as license plate number, scars, birth marks, eye color, tattoos, etc...</p>
</div>
</div>
</div>
</div>
</body>
</html>