PHP/MySQL modification code doesnt work, perplexing
Posted: Tue May 18, 2010 11:12 am
Greetings again, PHP technorati. Again, I grace your doorstep with another perplexing simple problem. I simply want
the code to not print anything if there is no data in the MySQL field. This code works on one part of the page, but
does not work in the other part. It prints [To]. I have tried remove the [To] by setting it as a variable, but the first part
of the code is ignored?!! Here is the code snipet:
Problem: it keeps printing the [To] even if the job_duty field is empty??!!
A similiar code works on the another part of the page. Please enlighten me as soon as
possible! Frustration factor is starting to increase.
Thanks in advance,
Batoe
the code to not print anything if there is no data in the MySQL field. This code works on one part of the page, but
does not work in the other part. It prints [To]. I have tried remove the [To] by setting it as a variable, but the first part
of the code is ignored?!! Here is the code snipet:
Code: Select all
<?
if ($info_1['job_duty_1'] == "") {
echo" ";
}
else {
print "<b>".$info_1['start_mo_1'] ." " .$info_1['start_yr_1'] ." ".$info_1['to']." ".$info_1['end_mo_1'] ." ".$info_1['end_yr_1'] ."</b><br>
<b>".$info_1['boss_1']."<BR>" .$info_1['job_title_1']."</b><BR>
<b>".$info_1['job_duty_1']. "</b><p>";
}
if ($info_1['job_duty_2'] == "") {
echo" ";
}
else {
print "<b>".$info_1['start_mo_2 '] ." " .$info_1['start_yr_2'] ." ".$info_1['to']." ".$info_1['end_mo_2'] ." ".$info_1['end_yr_2'] ."</b><br>
<b>".$info_1['boss_2']."<BR>" .$info_1['job_title_2']."</b><BR>
<b>".$info_1['job_duty_2']. "</b><p>";
}
if ($info_1['job_duty_3'] == "") {
echo" ";
}
else {
print "<b>".$info_1['start_mo_3'] ." " .$info_1['start_yr_3'] ." ".$info_1['to']." ".$info_1['end_mo_3'] ." ".$info_1['end_yr_3'] ."</b><br>
<b>".$info_1['boss_3']."<BR>" .$info_1['job_title_3']."</b><BR>
<b>".$info_1['job_duty_3']. "</b><p>";
}
if ($info_1['job_duty_4'] == "") {
echo" ";
}
else {
print "<b>".$info_1['start_mo_4'] ." " .$info_1['start_yr_4'] ." ".$info_1['to']." ".$info_1['end_mo_4'] ." ".$info_1['end_yr_4'] ."</b><br>
<b>".$info_1['boss_4']."<BR>" .$info_1['job_title_4']."</b><BR>
<b>".$info_1['job_duty_4']."</b><p>";
}
if ($info_1['job_duty_5'] == "") {
print" ";
}
else {
print "<b>".$info_1['start_mo_5'] ." " .$info_1['start_yr_5'] ." ".$info_1['to']." ".$info_1['end_mo_5'] ." ".$info_1['end_yr_5 '] ."</b><br>
<b>".$info_1['boss_5']."<BR>" .$info_1['job_title_5']."</b><BR>
<b>".$info_1['job_duty_5']."</b><p>";
}
if ($info_1['job_duty_6'] == "") {
print" ";
}
else {
print "<b>".$info_1['start_mo_6'] ." " .$info_1['start_yr_6'] ." ".$info_1['to']." ".$info_1['end_mo_6'] ." ".$info_1['end_yr_6 '] ."</b><br>
<b>".$info_1['boss_6']."<BR>" .$info_1['job_title_6']."</b><BR>
<b>".$info_1['job_duty_6']."</b><p>";
}
if ($info_1['job_duty_7'] == "") {
print" ";
}
else {
print "<b>".$info_1['start_mo_7'] ." " .$info_1['start_yr_7'] ." ".$info_1['to']." ".$info_1['end_mo_7'] ." ".$info_1['end_yr_7 '] ."</b><br>
<b>".$info_1['boss_7']."<BR>" .$info_1['job_title_7']."</b><BR>
<b>".$info_1['job_duty_7']."</b><p>";
}
if ($info_1['job_duty_8'] == "") {
print" ";
}
else {
print "<b>".$info_1['start_mo_8'] ." " .$info_1['start_yr_8'] ." ".$info_1['to']." ".$info_1['end_mo_8'] ." ".$info_1['end_yr_8 '] ."</b><br>
<b>".$info_1['boss_8']."<BR>" .$info_1['job_title_8']."</b><BR>
<b>".$info_1['job_duty_8']."</b><p>";
}
if ($info_1['job_duty_9'] == "") {
print" ";
}
else {
print "<b>".$info_1['start_mo_9'] ." " .$info_1['start_yr_9'] ." ".$info_1['to']." ".$info_1['end_mo_9'] ." ".$info_1['end_yr_9 '] ."</b><br>
<b>".$info_1['boss_9']."<BR>" .$info_1['job_title_9']."</b><BR>
<b>".$info_1['job_duty_9']."</b><p>";
}
if ($info_1['job_duty_10'] == "") {
print" ";
}
else {
print "<b>".$info_1['start_mo_10'] ." " .$info_1['start_yr_10'] ." ".$info_1['to']." ".$info_1['end_mo_10'] ." ".$info_1['end_yr_10 '] ."</b><br>
<b>".$info_1['boss_10']."<BR>" .$info_1['job_title_10']."</b><BR>
<b>".$info_1['job_duty_10']."</b><p>";
}
?>A similiar code works on the another part of the page. Please enlighten me as soon as
possible! Frustration factor is starting to increase.
Thanks in advance,
Batoe