Jump to content

Recommended Posts

Posted

I want to sort my airlines aircraft in ascending order when the pilot comes to choose his aircraft for submission of a pirep.

I have tried two ways so far.

in local config i did this.

/* Sort the aircraft by order*/
Config::Set('AIRCRAFT_ORDER_BY', 'name ASC');

That doesn't appear to work.

I also went into my mysql db and went into operations changing the alter table order from "id" to "name", but that doesnt seems to work either.

My php code on the pirep submit tpl is as follows, i wonder if someone could point me in the correct direction.

<div align="center">
     <select name="aircraft" id="aircraft">
       <option value="">Select the aircraft of this flight</option>
       <?php

	foreach($allaircraft as $aircraft)
	{
		$sel = ($_POST['aircraft'] == $aircraft->name || $bid->registration == $aircraft->registration)?'selected':'';

		echo '<option value="'.$aircraft->id.'" '.$sel.'>'.$aircraft->name.' - '.$aircraft->registration.'</option>';
	}
	?>
       </select>
     </div>

Thanks

Posted

If thats the case i'm wondering if its the operationsdata.class.php that would need the order_by, i'm sure there must be an easier way!

It would be easy as hell if you knew which query to add it to :P;)

Is it a drop down box you are wanting to order the results in?

EDIT: Sorry just looked at the code, and it is.

Posted

	/**
 * Get an aircraft according to registration
 */
public static function getAircraftByReg($registration)
{
	$registration = DB::escape(strtoupper($registration));

	$sql = 'SELECT * 
			FROM ' . TABLE_PREFIX .'aircraft
			ORDER BY name ASC 
			WHERE `registration`=\''.$registration.'\'';

	return DB::get_row($sql);
}

This is what I've just tried and it works, I added the ORDER BY to the query above, which is in the OperationsData.class.php file.

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.

Loading...
×
×
  • Create New...