Postingan lainnya
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 = '';
}
}
}
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>
coba ini <pre> <?php 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']; } else { $id_absence = $tab_att->fields['id_absence']; $emp_name = $tab_att->fields['emp_name']; $emp_position = ''; $company = ''; $position = ''; $email = $tab_att->fields['email']; $phone = '';
}
} </pre>