Jump to content

Something wrong with code


wellandg

Recommended Posts

I'm using pre-made PHP scripts for a virtual airline I run, but can't get an answer from the script author as to why (or how to correct) an error with input boxes. They show correct in Dreamweaver but on the website the hour and minute inputs are reversed.

 

It's difficult to explain in words so I have attached the scriped page and hope someone can find what is wrong. My PHP knowledge is very very limited.

 

Thanks

 

Gary Welland

 

[attachment deleted by admin]

Link to comment
Share on other sites

Instead of us having to download and unzip a zip file, could you just post the relevant code?

 

As I'm not sure where the code error may be I included the file. Here is the whole script then. The problem is at the bottom in the table with Flight Departure Time and Flight Duration. They do not line up and when clicking the drop down box, minutes show before hours.

 

<?
// $Id: addpirep.php,v 1.10 2006/10/05 07:25:45 hucklej Exp $
// Add a new PIREP
// Project Name:
// VAdmin2: Virtual Airline Administration Automation
// Project Customer:
// VAdmin2
// (c) James Huckle, 2004, 2005

include ("header.php");



$flights = get_flighttypes();

if (!$flights) {

echo "<div id=\"formstyle\">";
echo "<h2>Not enough data</h2>";
echo "</div>";
include ("footer.php");
exit;
}


$flights_select = "";
foreach ($flights as $each) {
$flights_select .= "<option value =\"$each\">$each</option>\n";

}


// put together an asset list to allocate a known fleet asset to the PIREP


echo "<SCRIPT language=\"Javascript\" src=\"CalendarPopup.js\"></SCRIPT>\n";

// add departure date and time
// also consider yes / no cofirmation of missing passenger lists

echo "<SCRIPT language=\"Javascript\">\n";

?>
	function populate_asset(type) {
<?


$ac = get_aircraft();
foreach ($ac as $each) {
//echo $each;
$assets = get_assets($each);

if ($assets != '') {
	// we have asset for this type


        $vars .= " document.pirep.asset.options.length = 0;";
	while (list($key, $val) = each ($assets)) {

		$vars .= "		var asset".$val['id']."=\"". $val['id']. "\";\n";
		$vars .= "		var asset_registration".$val['id']."=\"". $val['registration']. "\";\n";
		$vars .= "		var asset_type".$val['id']."=\"".$val['type']. "\";\n";
		$vars .= "		var asset_serial".$val['id']."=\"".$val['serial']. "\";\n";
		$vars .= "		var asset_purchasecost".$val['id']."=\"".$val['purchasecost']."\";\n";
		$vars .= "		var asset_purchasedate".$val['id']."=\"".$val['purchasedate']."\";\n";
            $vars .= "		var asset_name".$val['id']."=\"".$val['name']."\";\n";


		$logic .= "      if (type == '$each') {\n";
  		$logic .= "			var currentindex = document.pirep.asset.options.length;\n";
            $logic .= "         if (asset_name".$val['id']." =='') {asset_name".$val['id']." = 'NONE'}\n";

            $logic .= "         	document.pirep.asset.options[currentindex] = new Option(asset_registration".$val['id']."+', '+asset_name".$val['id'].", ".$val['id']."  )\n";


		$logic .= "      }\n";
	}
}
}

echo $vars;
echo $logic;

?>

}
<?

$route = new Route();
$routes = $route->getAll('false');


foreach ($routes as $id) {

$index = "";
$routename = "";
$dep_place = "";
$dep_code = "";
$arrival_place = "";
$arrival_code= "";
$aircraft = "";
$flight_type = "";
$frequency = "";
$category = "";
$hub = "";


while (list($key, $val) = each ($id)) {

	if ($key == "id") {
		$index = $val;
		$routelist[] = $index;
	}

	if ($key == "routename") {
		$routename = $val;
		$routenames[$index] = $routename;
	}

	if ($key == "depart_place") {
		$dep_place = $val;
	}
	if ($key == "depart_code") {
		$dep_code = $val;
	}
	if ($key == "arrive_place") {
		$arrival_place = $val;
	}
	if ($key == "arrive_code") {
		$arrival_code = $val;
	}
	if ($key == "aircraft") {
		$aircraft = $val;
	}
	if ($key == "flight_type") {
		$flight_type = $val;
	}
	if ($key == "frequency") {
		$frequency = $val;
	}
	if ($key == "category") {
		$category = $val;
	}
	if ($key == "hub") {
		$hub = $val;
	}
}
echo "var id$index  = \"$index\";\n";
echo "var routename$index  = \"$routename\";\n";
echo "var dep_place$index  = \"$dep_place\";\n";
echo "var dep_code$index  = \"$dep_code\";\n";
echo "var arrival_place$index  = \"$arrival_place\";\n";
echo "var arrival_code$index  = \"$arrival_code\";\n";
echo "var aircraft$index  = \"$aircraft\";\n";
echo "var flight_type$index  = \"$flight_type\";\n";
echo "var frequency$index  = \"$frequency\";\n";
echo "var category$index  = \"$category\";\n";
echo "var hub$index  = \"$hub\";\n";

}
echo "function populate(id) {\n";

foreach ($routelist as $each) {

echo " if (id == $each) {\n";

echo "document.pirep.dep_code.value = null\n";
echo "document.pirep.dep_code.value = dep_code$each;\n";

echo "document.pirep.dep_place.value = null\n";
echo "document.pirep.dep_place.value = dep_place$each;\n";

echo "document.pirep.arr_code.value = null\n";
echo "document.pirep.arr_code.value = arrival_code$each;\n";

echo "document.pirep.arrival_place.value = null\n";
echo "document.pirep.arrival_place.value = arrival_place$each;\n";

echo "document.pirep.aircraft.value = null\n";
echo "document.pirep.aircraft.value = aircraft$each;\n";

echo "document.pirep.flight_type.value = null\n";
echo "document.pirep.flight_type.value = flight_type$each;\n";

echo "document.pirep.hub.value = null\n";
echo "document.pirep.hub.value = hub$each;\n";
echo "populate_asset(aircraft$each);\n";
echo "}\n";
}



echo "}\n";

$pilotdetails = get_pilotdetails();

foreach ($pilotdetails as $pilot) {
$index = "";
$fullname = "";
$vatsimid = "";
$vadminid = "";

while (list($key, $val) = each ($pilot)) {

	if ($key == "id") {
		$index = $val;
		$pilotlist[] = $index;
	}
	if ($key == "fullname") {
		$fullname = $val;
	}
	if ($key == "vatsimid") {
		$vatsimid = $val;
	}
	if ($key == "vadminid") {
		$vadminid = $val;
	}
}

echo "var pilot$index"."_fullname = \"$fullname\";\n";
echo "var pilot$index"."_vadminid = \"$vadminid\";\n";
echo "var pilot$index"."_vatsimid = \"$vatsimid\";\n";

}
echo "function populate_pilot(id) {\n";

foreach ($pilotlist as $each) {

echo "if (id == $each) {\n";
echo "document.pirep.vadminid.value = null\n";
echo "document.pirep.vadminid.value = pilot$each"."_vadminid;\n";
echo "}\n";
}

echo "}\n";

echo "</SCRIPT>\n";

$fields = array(
"missing_pilot" => "pilot",
"missing_vadminid" => "vadminid",
"missing_aircraft_type" => "aircraft",
"missing_flight_type" => "flight_type",
"missing_flightdate" => "flightdate",
"missing_departurecode" => "dep_code",
"missing_departureplace" => "dep_place",
"missing_arrivalcode" => "arr_code",
"missing_arrivalplace" => "arrival_place",
"missing_hub" => "hub",
"missing_VA_ID" => "vadminid",	
);

echo get_jscriptValidation($fields, "pirep");

?>

<div class="content2">
<div class="content2-pagetitle">PIREP</div>	
<div class="content-txtbox-noshade">
	<div class="content-title-noshade-size2">Add PIREP</div>
	<form action="do_addpirep.php" method="post" name="pirep" onsubmit="return checkForm(this);">			
	<table>
		<tr>
			<th>Pilot Details</th>
			<th></th>
		</tr>
		<tr>
			<td>Pilots Name</td>
			<td>
		<? if ($idiot_pireps == '1') { 

		$pilotcookie = get_pilotnamefromid($_COOKIE['vadmin_myid']);		

			?>
			<input disabled type="text" size="20" id="pilotname" name="pilotname" value="<? echo $pilotcookie ?>">
			<input type="hidden" size="20" id="pilot" name="pilot" value="<? echo $_COOKIE['vadmin_myid'] ?>">
			<?
			} else { 
			?>


		<select name="pilot" id="pilot" onchange="populate_pilot(document.pirep.pilot.options[document.pirep.pilot.selectedIndex].value); return false;">
		<option value="0">- Select -</option>
			<?
			// pilot multiselect
			$pilotcookie = get_pilotnamefromid($_COOKIE['vadmin_myid']);
			$pilots = get_pilots();
			foreach ($pilots as $pilot) {
				while (list($key, $val) = each ($pilot)) {
					if ($key == "id") {
						$index = $val;
					}
					if ($key == "fullname") {
						$fullname = $val;
					}
				}
				if ($index == $_COOKIE['vadmin_myid']) {
					echo "<option selected value =\"$index\">$fullname</option>\n";
				} else {
					echo "<option value =\"$index\">$fullname</option>\n";
				}
			}
			?>
			</select>
			<?
			} 
			?>

		</td>

		</tr>

		<tr>
			<td>VAdmin ID</td>
			<td><input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type="text" size="12" id="vadminid" name="vadminid" value="<? echo $_COOKIE['vadmin_vadminid'] ?>"></td>
		</tr>
		<tr>
			<td>VATSIM ID</td>

			<td><input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type="text" size="12" id="vatsimid" name="vatsimid" value="<? echo $_COOKIE['vadmin_vatsimid'] ?>"></td>
		</tr>



		<tr>
			<th>Route Details</th>	
			<th></th>
		</tr>
		<tr>
			<td>Route ID</td>
			<td><select name="routeid" id="routeid" onChange = "populate(document.pirep.routeid.options[document.pirep.routeid.selectedIndex].value); return false;">
			<option value="0">- Select -</option>
	<?
	foreach ($routelist as $each) {
		echo "<option value =\"$each\">$each - $routenames[$each]</option>";
	}
	?>
		</select></td>
		</tr>




		<tr>
			<td>Aircraft Type</td>
			<td>
			<? if ($idiot_pireps == '1') { 
			?>
			<input disabled type="text" size="20" id="aircraft" name="aircraft">

			<?
			} else { 
			?>
			<select name="aircraft">
			<option value="0">- Select -</option>
	<?
	# aircraft select
	$ac = get_aircraft();
	foreach ($ac as $each) {
		echo "<option value =\"$each\">$each</option>\n";
	}
	?>
				</select>
				<?
			} 
			?>
			</td>
		</tr>




	    <tr>
	 		<td>Asset</td>
	        <td><select name="asset"></select></td>        
	    </tr>


		 <tr>
	 		<td>Flight Type</td>
	        <td>
			<? if ($idiot_pireps == '1') { 
			?>
			<input disabled type="text" size="20" id="flight_type" name="flight_type">

			<?
			} else { 
			?>
			<select name="flight_type">
			<option value="0">- Select -</option>
			<?echo $flights_select?>
			</select>
			<?
			} 
			?>
			</td>        
	    </tr>



		<tr>
	 		<td><? echo $labelprefs['Departure'] ?></td>
	        <td>
				Code <input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type="text" size="5" id="dep_code" name="dep_code">
				Location <input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type ="text" size="20" id="dep_place" name="dep_place">
			</td>        
	    </tr>
	    
		<tr>
	 		<td><? echo $labelprefs['Arrival'] ?></td>
	        <td>
				Code <input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type="text" size="5" id="arr_code" name="arr_code">
				Location <input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type="text" size="20" id="arrival_place" name="arrival_place">
			</td>        
	    </tr>




		<tr>
	 		<td>Hub</td>
	        <td><input <? if ($idiot_pireps == '1') { echo "disabled"; } ?> type="text" size="4" id="hub" name="hub"></td>        
	    </tr>

		<tr>
	 		<th>Flight Details</th>
	        <th></th>
	    </tr>


		<tr>
	 		<td>Passengers</td>
	        <td><input type="text" size="12" id="passengers" name="passengers"></td>        
	    </tr>



		<tr>
	 		<td>Cargo load</td>
	        <td><input type="text" size="12" id="cargo" name="cargo"><select name="units" id="units"><option selected="selected" value="0">- Select -</option><option value="kgs">kgs</option><option value="lbs">lbs</option></select></td>        
	    </tr>
		<tr>
	 		<td><? echo $labelprefs['departure_date'] ?> <a href="#" onclick="cal1.select(document.pirep.flightdate,'anchor1','<? echo $inputdateformat ?>'); return false;" title="Date Picker" name="anchor1" id="anchor1">[Choose]</a></td>
	        <td><input type="text" size="12" id="flightdate" name="flightdate" value="<? echo get_formattedDate() ?>"></td>        
	    </tr>
		<tr>
	 		<td>Flight Departure Time</td>
	        <td> hrs 
			<select name="dep_hour">
			<option value="00" selected >00</option>
	<?
	echo numeric_option(1, 23, 1);
	?>
			</select> mins 
			<select name="dep_min">
			<option value="00" selected>00</option>
	<?
	echo numeric_option(1, 59, 1);
	?>
			</select></td>        
	    </tr>
	    
	    
		<tr>
	 		<td>Flight Duration</td>
	        <td> hrs 
			<select name="duration_hour">
			<option value="00" selected >00</option>
	<?
	echo numeric_option(1, 23, 1);
	?>
			</select> mins 
			<select name ="duration_min">
			<option value="10" selected>0.10</option>
			<option value="20" >0.20</option>
			<option value="30" >0.30</option>
			<option value="40" >0.40</option>
			<option value="50" >0.50</option>
			<option value="60" >0.60</option>
			<option value="70" >0.70</option>
			<option value="80" >0.80</option>
			<option value="90" >0.90</option>
			<option value="1"  >1.00</option>
			</select></td>        
	    </tr>
	    <tr>
	 		<td valign="top">Log incident</td>
	        <td><textarea name="incident" id="incident" cols="50" rows="5"></textarea></td>        
	    </tr>
		<tr>
	 		<td> </td>
	        <td><input type="submit" value="Log Entry"></td>        
	    </tr>
	    
	    
		<tr>
	 		<td colspan="2">DECIMAL FLIGHT TIME TO BE USED</td>
	 	</tr>
		<tr>
	 		<td colspan="2">00-06 MINUTES = 0.1 / 07-12 MINUTES = 0.2</td>
	 	</tr>
		<tr>
	 		<td colspan="2">13-18 MINUTES = 0.3 / 19-24 MINUTES = 0.4</td>
	 	</tr>
		<tr>
	 		<td colspan="2">25-30 MINUTES = 0.5 / 31-36 MINUTES = 0.6</td>
	 	</tr>
		<tr>
	 		<td colspan="2">37-42 MINUTES = 0.7 / 43-48 MINUTES = 0.8</td>
	 	</tr>
		<tr>
	 		<td colspan="2">49-54 MINUTES = 0.9 / 55-60 MINUTES = 1.0</td>
	 	</tr>


	</table>


</form>

</div>
</div>
<?
include ("footer.php");
?>

 

Please use the code tags (


) when posting code. Thank you

 

Link to comment
Share on other sites

Erm.. code tags would be been nice.. also this a kinda php/javascript problem.. have you tried viewing the parsed file to see if its correct ? if so its a JS problem if not you shoud see what part is wrong and beable to post the problem section!

 

Hopefully picture attached may help more

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.