I'm fetching data from a database that has some empty fields here and there, therefore I have some if statements in my code, but I can't seem to find the mistake in them. Here are some examples:
Get actual title (of candidate):
As you can see, there's the possibility that the field is at either place 5 or 6 in the array of a candidate.
if(array_key_exists(5, $FL) == true && $FL[5]->val == 'Actual title') {
$currentTitle = $FL[5]->content;
} else if (array_key_exists(6, $FL) == true && $FL[6]->val == 'Actual title') {
$currentTitle = $FL[6]->content;
} else {
$currentTitle = $notSpecified;
}
Here's how I get the skills:
if(array_key_exists(5, $FL) == true && $FL[5]->val == 'Kompetencer') {
$skills = $FL[5]->content;
$parts = explode(',', $skills);
$result = implode(', ', $parts);
$skills = $result;
} else if (array_key_exists(6, $FL) == true && $FL[6]->val == 'Kompetencer') {
$skills = $FL[6]->content;
$parts = explode(',', $skills);
$result = implode(', ', $parts);
$skills = $result;
} else {
$skills = $notSpecified;
}
I print these in a table. For some reason I can execute the code the first time, and it shows e.g. "CEO" as actual title, but not the associated skills. Then I can refresh 10 times or something and suddenly it doesn't show the title but only the skill. Skill and actual title are seperate columns in the table. Is there a hole in my logic somewhere?
It's really hard for me to figure it out since I don't get any error messages and I'm relatively new to PHP.
Aucun commentaire:
Enregistrer un commentaire