bgmn cara menampilkan: jika redir_id not null, maka dia tampil semua, tapi kondisi null juga tampil


<?php
$n_att   = 1;
$tab_att = $db_home->Execute("SELECT * FROM mtg_absence WHERE  id_main = '" . $get_id_main . "'");

while(!$tab_att->EOF) {
	if($_SESSION['redir_id'] !== NULL)){
		$id_absence   = $tab_att->fields['id_absence'];
		$emp_name     = $tab_att->fields['emp_name'];
		$emp_position = $tab_att->fields['emp_position'];
		$company      = $tab_att->fields['plan_name'];
		$position     = ($company) ? $company . " - " . $emp_position : $emp_position;
		$email        = $tab_att->fields['email'];
		$phone        = $tab_att->fields['phone'];
	if($_SESSION['redir_id'] == NULL){
		$id_absence   = $tab_att->fields['id_absence'];
		$emp_name     = $tab_att->fields['emp_name'];
		$emp_position = '';
		$company      = '';
		$position     = '';
		$email        = $tab_att->fields['email'];
		$phone        = '';
		}
		}
	}

avatar elnian
@elnian

1 Kontribusi 0 Poin

Diperbarui 5 tahun yang lalu

2 Jawaban:

<pre> If ( $_Session['redir_id'] !== Null or $_Session['redir_id'] === Null ) { // Your code here dude... } </pre>

Atau bisa pakai seperti pada baris company

<pre> $null = ( $_Session['redir_id'] === Null ? echo 'null'; : echo 'tidak null'; ); </pre>

avatar tompradana
@tompradana

134 Kontribusi 95 Poin

Dipost 5 tahun yang lalu

coba ini <pre> &lt;?php while(!$tab_att-&gt;EOF) { if($_SESSION['redir_id'] !== NULL){ $id_absence = $tab_att-&gt;fields['id_absence']; $emp_name = $tab_att-&gt;fields['emp_name']; $emp_position = $tab_att-&gt;fields['emp_position']; $company = $tab_att-&gt;fields['plan_name']; $position = ($company) ? $company . " - " . $emp_position : $emp_position; $email = $tab_att-&gt;fields['email']; $phone = $tab_att-&gt;fields['phone']; } else { $id_absence = $tab_att-&gt;fields['id_absence']; $emp_name = $tab_att-&gt;fields['emp_name']; $emp_position = ''; $company = ''; $position = ''; $email = $tab_att-&gt;fields['email']; $phone = '';

}

} </pre>

avatar dianarifr
@dianarifr

642 Kontribusi 316 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban