Jump to content

comments on the pilot public


FlightDeckES
 Share

Recommended Posts

Hello 

I need your help please I am trying to make the comments visible in the pirep_viewreport

I am using this code

 

 <?php
foreach($comments as $comment)
{
?>               

<p id="row ">
<strong><?php echo $comment->firstname. ' '. $comment->lastname ?>: </strong><?php echo $comment->comment; ?>
<hr />
</p>

<?php
}
?>  
 

http://i65.tinypic.com/2zibvut.png


  but I have this error thanks for the help thanks 

 

Link to comment
Share on other sites

  • Moderators
6 hours ago, sotofigueroa26 said:

foreach($comments as $comment)
{

The error refers to the loop of your code. in fact you haven't set $comments variable to get the required data. You need to first get the data from your DB field and then use the loop to show every records. In order to do so, you need a function that reads records from your table in your DB.

Link to comment
Share on other sites

Hi,

thanks for the help with this code I solved the error but now it gives me another.

Here it works right with comments.

http://i68.tinypic.com/6z95wm.png

here it does not work without comments

http://i68.tinypic.com/zl7l0i.png

code:

 


<!-- Comentarios -->
<div class="card">
<div class="card-title">
<i class="fa fa-commenting-o"></i>
<span class="caption-subject bold uppercase"> Comentarios </span>
</div>
<div class="card-body">
                
<?php            
if(!$comments)
{
    echo '<p align="center"><strong>There are no comments for this PIREP</strong></p>';

    return;
}
?>
<div id="dialogresult"></div>
<?php
foreach($comments as $comment)
{
?>
<p id="row<?php echo $comment->id;?>">
<strong><?php echo $comment->firstname. ' '. $comment->lastname ?>: </strong><?php echo $comment->comment; ?>
<hr />
</p>
<?php
}
?>

<form action="<?php echo url('/pireps/viewpireps');?>" method="post">
<textarea name="comment" style="width:100%; height: 100px"></textarea>
<input type="hidden" name="action" value="addcomment" />
<input type="hidden" name="pirepid" value="<?php echo $pirep->pirepid?>" />
<input type="submit" name="submit"class="btn btn-primary btn-block" value="Añadir" />
</div>
</div>
<!-- Comentarios  --> 

 

 

 

Edited by sotofigueroa26
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...