What's new

PHP Mga IT Gods Need your help

Status
Not open for further replies.
nakikita mo yung "All"
pindutin mo yon
1656263347367.png
 

Attachments

solve na?

<td>
<p class="m-0">
<?php
if($row['type'] == 1){
echo = "Administrator";
}
if($row['type'] == 2){
echo = "Staff";
}
if($row['type'] == 3){
echo = "Process Owner";
}
if($row['type'] == 4){
echo = "Auditor";
}
if($row['type'] == 5){
echo = "Auditor Lead";
}
if($row['type'] == 6){
echo = "QAH";
}
if($row['type'] == 7){
echo = "Team Management";
}
if($row['type'] == 8){
echo = "Human Resource";
}

?>
</p>
</td>

try this
 
Last edited:
solve na?

<td>
<p class="m-0">
<?php
if($row['type'] == 1){
echo = "Administrator";
}
if($row['type'] == 2){
echo = "Staff";
}
if($row['type'] == 3){
echo = "Process Owner";
}
if($row['type'] == 4){
echo = "Auditor";
}
if($row['type'] == 5){
echo = "Auditor Lead";
}
if($row['type'] == 6){
echo = "QAH";
}
if($row['type'] == 7){
echo = "Team Management";
}
if($row['type'] == 8){
echo = "Human Resource";
}

?>
</p>
</td>

try this
ahahahah ganyan nga mas madali e kaso gusto niya ternary operation HAHAHA
 
Huwag ka mag daisy chain ng if/else. Either mag-map ka ng array or switch() kung walang choice.

Mag declare ka ng array na yung number ang key tapos yung value yung role string. Tapos gamitin mo yung $row['type'] as key ng bagong gawang $roles array.

Code:
<?php
    $roles = [
        1 => 'Administrator',
        2 => 'Staff',
        3 => 'Process Owner',
        4 => 'Auditor',
        5 => 'Auditor Lead',
        6 => 'QAH',
        7 => 'Team Management',
        8 => 'Human Resource'
    ];
?>

<td ><p class="m-0"><?php echo( $roles[$row['type']] ) ?></p></td>
 
Last edited:
Lods try mo din php pdo mas madali at malinis tingnan codes mo at lalong lalo na sa pag trace.
 
Last edited:
Try mo yung akin, mas maiksi. Bad newbie habit yang mahabang if-else kung pwede naman mag reference sa array of values, wag mong sanayin sarili mo sa spaghetti coding.
 
Last edited:
Status
Not open for further replies.

Similar threads

Back
Top