zhangy Posted June 1, 2009 Share Posted June 1, 2009 Hello, I have the tables rows in mysql database echoing out listed by their submission id number. What I am trying to do is have it so the most current row on the list will stand out with a larger font than the the previous rows in the list. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/ Share on other sites More sharing options...
aashcool198 Posted June 1, 2009 Share Posted June 1, 2009 can you post the part of the code you are using? will be easier to figure out. Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846745 Share on other sites More sharing options...
zhangy Posted June 1, 2009 Author Share Posted June 1, 2009 <?php $sql = "SELECT * FROM $table ORDER BY id DESC LIMIT 25"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); if(mysql_num_rows($result) >= 1) { echo '<div id="front_page_post_container">'; while($row = mysql_fetch_array($result)) { echo '<div id="hover_div">'; echo '<div id="title_container">'; echo '<h2>'; echo '<a href="post.php?id='.$row['id'].'">'.stripslashes($row['title']).'</a>'; echo '</h2>'; echo '</div>'; echo '<div id="post_container">'; echo stripslashes(nl2br(substr($row['post'],0,450))); echo ' <a href="post.php?id='.$row['id'].'">Read on...</a>'; echo '</div>'; Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846751 Share on other sites More sharing options...
zhangy Posted June 1, 2009 Author Share Posted June 1, 2009 Any ideas? suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846918 Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 have a counter variable initiated before your while loop and set it to zero. inside the loop check this variable. if it is zero, highlight the current item however you want, then increment the counter. then as it goes through the loop no other entry will be highlighted Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846927 Share on other sites More sharing options...
zhangy Posted June 1, 2009 Author Share Posted June 1, 2009 Not sure how to right that. Can you point me in the right direction? <?php $sql = "SELECT * FROM $table ORDER BY id DESC LIMIT 25"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); if(mysql_num_rows($result) >= 1) { $count = mysql_num_rows($result); if { $class = '0'; }else{ $class = ''; } echo '<div id="front_page_post_container">'; while($row = mysql_fetch_array($result)) { echo '<div id="hover_div" class="{$class}">'; echo '<div id="title_container">'; echo '<h2>'; echo '<a href="post.php?id='.$row['id'].'">'.stripslashes($row['title']).'</a>'; echo '</h2>'; echo '</div>'; echo '<div id="post_container">'; echo stripslashes(nl2br(substr($row['post'],0,450))); echo ' <a href="post.php?id='.$row['id'].'">Read on...</a>'; echo '</div>'; Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846968 Share on other sites More sharing options...
Ken2k7 Posted June 1, 2009 Share Posted June 1, 2009 Well before I even get into the more technical aspect of this, do you know how to use an IF statement? if { $class = '0'; }else{ $class = ''; } ??? Google that. I'm going to let you figure out what's wrong. Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846991 Share on other sites More sharing options...
zhangy Posted June 1, 2009 Author Share Posted June 1, 2009 Ok i see what you mean, but I tried the following and it has no effect. <?php $sql = "SELECT * FROM $table ORDER BY id DESC LIMIT 25"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); if(mysql_num_rows($result) >= 1) { echo '<div id="front_page_post_container">'; $RsCounter = 0; while($row = mysql_fetch_array($result)) { $RsCounter++; if($RsCounter == 0){ echo '<div id="hover_div" style="font-size: 15px; font-weight: bold;">'; } else { echo '<div id="hover_div">'; } echo '<div id="title_container">'; echo '<h2>'; echo '<a href="post.php?id='.$row['id'].'">'.stripslashes($row['title']).'</a>'; echo '</h2>'; echo '</div>'; echo '<div id="post_container">'; echo stripslashes(nl2br(substr($row['post'],0,450))); echo ' <a href="post.php?id='.$row['id'].'">Read on...</a>'; echo '</div>'; echo '</div>'; } echo '</div>'; } else { echo "That record does not exist!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-846999 Share on other sites More sharing options...
lonewolf217 Posted June 1, 2009 Share Posted June 1, 2009 <?php $RsCounter = 0; while($row = mysql_fetch_array($result)) { $RsCounter++; if($RsCounter == 0){ echo '<div id="hover_div" style="font-size: 15px; font-weight: bold;">'; } else { echo '<div id="hover_div">'; } you are incrementing the counter before you ever check it. Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-847002 Share on other sites More sharing options...
zhangy Posted June 1, 2009 Author Share Posted June 1, 2009 Oh i see! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/160456-solved-row-display-question/#findComment-847019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.