auurk auurk - 2 months ago 50
PHP Question

Mark latest/largest entry

I have a table with documents and want to list them. I would like the latest entry to be red. How can I do that?

$q = "SELECT * FROM documents WHERE uid = '$uid'";
$r = mysqli_query($dbc, $q);
while($row=mysqli_fetch_assoc($r)){ ?>

<p <?php if(this doc has the largest docid){style="color=red;"} ?>><?php echo $row['doctitle']; ?></p></br>

<?php }


Answer Source
$q = "SELECT * FROM documents WHERE uid = '$uid' ORDER BY ID DESC ";
$r = mysqli_query($dbc, $q);

$i = 1;
while($row=mysqli_fetch_assoc($r)){ ?> 

<p <?php if($i == 1)echo 'style="color=red;'; ?>><?= $row['doctitle'] ?></p>
<?php }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download