php color change

I just need to change the text color

public function prepare_fields() {
$data = $this->data;

	$fields = array(
		'membership_id' => array(
			'id' => 'membership_id',
			'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,
			'value' => $data['membership_id'],
		),

		'first_name' => array(
			'id' => 'first_name',
			'title' => $data['label_first_name'],
			'placeholder' => $data['hint_first_name'],
			'type' => MS_Helper_Html::INPUT_TYPE_TEXT,
			'value' => $data['first_name'],
		),

		'last_name' => array(
			'id' => 'last_name',
			'title' => $data['label_last_name'],
			'placeholder' => $data['hint_last_name'],
			'type' => MS_Helper_Html::INPUT_TYPE_TEXT,
			'value' => $data['last_name'],
		),

		'username' => array(
			'id' => 'username',
			'title' => $data['label_username'],
			'placeholder' => $data['hint_username'],
			'type' => MS_Helper_Html::INPUT_TYPE_TEXT,
			'value' => $data['username'],
		),

		'email' => array(
			'id' => 'email',
			'title' => $data['label_email'],
			'placeholder' => $data['hint_email'],
			'type' => MS_Helper_Html::INPUT_TYPE_TEXT,
			'value' => $data['email'],
		),

		'password' => array(
			'id' => 'password',
			'title' => $data['label_password'],
			'placeholder' => $data['hint_password'],
			'type' => MS_Helper_Html::INPUT_TYPE_PASSWORD,
			'value' => '',
		),

		'password2' => array(
			'id' => 'password2',
			'title' => $data['label_password2'],
			'placeholder' => $data['hint_password2'],
			'type' => MS_Helper_Html::INPUT_TYPE_PASSWORD,
			'value' => '',
		),

		'action' => array(
			'id' => 'action',
			'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,
			'value' => $data['action'],
		),

		'step' => array(
			'id' => 'step',
			'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,
			'value' => $data['step'],
		),
	);

	return $fields;
}

/**
 * Renders error messages.
 *
 * @access private
 */
private function render_errors() {
	if ( ! empty( $this->data['errors'] ) ) {
		?>
		<div class="ms-alert-box ms-alert-error">
			<?php echo $this->data['errors']; ?>
		</div>
		<?php
	}
}

That is handled with css not php.

I have a script that echo’s mysql table values, I can set the colours etc based upon the output using;-

[php]if($row[‘TBL_ROW1’]==‘COMPLETE’)
echo “

”.$row[‘TBL_ROW1’]."";

else if($row[‘TBL_ROW1’]==‘LIVE’)
echo “

”.$row[‘TBL_ROW1’].""; [/php]

This certainly helps me but not sure if you could use this?

That is twice the amount of code you need to do that.

Hi Kevin,

Would you mind posting the code that will cut mine down please? I’m always looking to improve my code.

thanks

[php]$status = $row[‘TBL_ROW1’]==‘COMPLETE’ ? ‘primary’ : ‘danger’;
echo “

”.$row[‘TBL_ROW1’]."";[/php]

Cheers Kevin, worked a treat! :slight_smile:

That is the ternary operator. Here is a simple explanation:

http://www.hackingwithphp.com/3/12/4/the-ternary-operator

You can do more complicated things with it, such as nested ternarys, but it starts getting hard to read.

Sponsor our Newsletter | Privacy Policy | Terms of Service