I need a solution for a php based website. I have a testimonial in homepage page in which the content should be dynamically displayed from the back-end. and also i need a conditional statement for it. If the testimonial is approved from back-end, then display the content in homepage, if not , do not show.
Html mainpage Codes
<aside id="home-marketing-testimonials">
<span class="section_title"><h6 style="color:#fff200; font-weight:bold;">Our Students Say it Best</h6></span>
<div class="testimonials" style="text-align:justify;">
<div class="testimonial">
<blockquote style="color:#fff;">
<?php
$nsql = mysql_query("select * from testimonials order by id desc limit 0,1");
while($nrow = mysql_fetch_array($nsql))
{
?>
<?php echo $nrow[5]; ?></a></strong>
<?php
$nrowlen = strlen($nrow[1]);
if($nrowlen > 220)
{
echo substr($nrow[1],0,220)."...";
}
else
{
echo "<div style='font-size:12px;color:yellow; margin-top:10px;'>".$nrow[1]."</div>";
}
?>
</blockquote>
<?php
}
?>
<strong class="client_identity" style="color:#fff; float:left;"><a class="test_author" href="students-testimonials.php"></a></strong>
</div>
</div>
</aside>
Backend testimonial code:
<div class="content_display">
<div class="widgetcontent bordered">
<div class="row-fluid">
<!--<div align="right"><a href="add_pages.php" style="margin-bottom: 10px; color:#fff;" class="btn btn-primary">Add New</a></div>-->
<table class="table table-bordered" width="100%">
<colgroup>
<col class="con0" />
<col class="con1" />
<col class="con0" />
<col class="con1" />
<col class="con0" />
<col class="con1" />
</colgroup>
<thead>
<tr>
<th width="10%">S.No</th>
<th width="20%">Name</th>
<th width="20%">Student ID</th>
<th width="20%">Email</th>
<th width="10%">Status</th>
<th width="20%">Options</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
$sql=mysql_query("select * from testimonials order by id desc");
while($res=mysql_fetch_array($sql))
{
?>
<tr>
<td ><?php echo $i; ?></td>
<td><?php echo $res['name']; ?></td>
<td><?php echo $res['stuid']; ?></td>
<td><?php echo $res['email']; ?></td>
<td><?php
if($res['cstatus']=="0")
{
echo "Disapproved";
}
else
{
echo "Approved";
}
?>
</td>
<td>
<a href="view_testimonial.php?id=<?php echo $res['id']; ?>">View</a>
<?php
if($res['cstatus']=="0")
{
echo '<a href="approve.php?id='.$res['id'].'">Approve</a>';
}
else
{
echo '<a href="disapprove.php?id='.$res['id'].'">Disapprove</a>';
}
?>
<a href="#" onClick="ConfirmChoice(<?php echo $res['id']; ?>);">Delete</a></td>
</tr>
<?php
$i++; }?></tbody></table></div></div></div>