Forum Moderators: coopster
This is the error I keep getting:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/9501/domains/testing/html/testing/portfolio/portfolio_all_if.php on line 190
Here is the unmodified region with no IF statment:
<a href="proj_detail.php?job_id=<?php echo $row_proj_list_all['job_id'];?>"><strong><?php echo $row_proj_list_all['job_name'];?></strong><br />
<?php echo $row_proj_list_all['job_sub_name'];?>
</a>
Here is my attempt at making the href appear if the correct condition is met:
<?php
if ($totalRows_proj_list_all['job_detail'] == 0) { // Show if recordset not empty
echo "<a href=\"proj_detail.php?job_id=$row_proj_list_all['job_id']\"><strong> $row_proj_list_all['job_name'] </strong><br />
$row_proj_list_all['job_sub_name']
</a>";
} // Show if recordset not empty
elseif ($totalRows_proj_list_all['job_detail'] == 1) { // do not show if recordset empty
echo "<strong>$row_proj_list_all['job_name']; </strong><br />
$row_proj_list_all['job_sub_name'];?
</a>";
} // do not show if recordset empty?>
Thanks,
Alex
Try something like this. You cannot have array values within a string like you do.
<?php
if($totalRows_proj_list_all['job_detail'] == 0) {
echo '<a href="proj_detail.php?job_id='.$row_proj_list_all['job_id'].'"><strong>' .$row_proj_list_all['job_name'].'</strong><br />'.$row_proj_list_all['job_sub_name'].'</a>';
}
else if($totalRows_proj_list_all['job_detail'] == 1) {
echo '<strong>'.$row_proj_list_all['job_name'].'</strong><br />'.$row_proj_list_all['job_sub_name'];
}
?>
For reference, you should take a quick read of Strings Documentation [us3.php.net].
Good luck! :)