I'm starting a small online site which has content in an "issue". Here is my code to collect that:
<?php
$issue_sql = "SELECT * FROM issues WHERE id = '$id'"; // From URL
$issue_res = mysqli_query($con, $issue_sql);
while($issue = mysqli_fetch_assoc($issue_res)){
$issue_id = $issue["id"];
$issue_added = $issue["added"];
$issue_content = $issue["content"];
$issue_endorsed = $issue["endorsed"];
$issue_year = date("Y", strtotime($issue_added));
$issue_date = date("l jS F, Y", strtotime($issue_added));
}
?>
And I want to display the endorsement only if it exists (Which in this case it does). So my code for this is:
<?php
if($issue_endorsed === 1){
$endorsed_sql = "SELECT article FROM issue_endorsed WHERE id = '$issue_id'";
$endorsed_res = mysqli_query($con, $endorsed_sql);
while($endorsed = mysqli_fetch_assoc($endorsed_res)){
$endorsed_article = $endorsed["article"];
$display_endorsed = "
<div class=\"section\">
<div class=\"sectionText\">
<b>We Recommend ...</b>
<br>
... $endorsed_article
</div>
</div>
<div class=\"contentDivideSecondary\"></div>
";
}
}else{
$display_endorsed = "Not Here";
};
?>
The problem is, when I <?php echo display_endorsed; ?> later on in the html code, I'm shown the Not Here instead of the actual content. Can anyone see where I'm going wrong?
$issue_endorsedvariable a integer or a string?===, usevar_dumpto tell===to==and it's now working fine, so I guess there was an issue in there somewhere. Thanks