BNole Posted November 27, 2007 Share Posted November 27, 2007 My code below works (thanks to you guys). However, I only want there to be those final two line breaks if it ISN'T the last row to be printed. In this example, Row 5 shouldn't have line breaks at the end. Do I need to add another loop / if to check this...or am I missing a simpler solution? Thanks. <?php $con = mysql_connect("localhost","*****","*****"); if (!$con) { die('Could Not Connect: ' . mysql_error()); } mysql_select_db("firecoac_firecoachtiller", $con); $result = mysql_query("SELECT comments, signature FROM fanthefire ORDER BY added DESC LIMIT 0, 6", $con); while ($row = mysql_fetch_assoc($result)) { echo '<div class="letter">'; echo '"'; echo $row['comments']; echo '"'; echo '</div>'; echo '<div class="signature">'; echo '- '; echo $row['signature']; echo '</div><br /><br />'; } mysql_close($con);?> Link to comment Share on other sites More sharing options...
Synook Posted November 27, 2007 Share Posted November 27, 2007 You could increment a variable and use mysql_num_rows() to check whether you are at the end <?php$con = mysql_connect("localhost","*****","*****");if (!$con){die('Could Not Connect: ' . mysql_error());}mysql_select_db("firecoac_firecoachtiller", $con);$result = mysql_query("SELECT comments, signature FROM fanthefire ORDER BY added DESC LIMIT 0, 6", $con);$rownum = 1;while ($row = mysql_fetch_assoc($result)){echo '<div class="letter">';echo '"';echo $row['comments'];echo '"';echo '</div>';echo '<div class="signature">';echo '- ';echo $row['signature'];if ($rownum++ != mysql_num_rows($result)) echo '</div><br /><br />';}mysql_close($con); Link to comment Share on other sites More sharing options...
Guest bboyse Posted November 27, 2007 Share Posted November 27, 2007 hy, somebody can tell me how i put request, exemple, i want to make one registration page, and i put there username, password and email, but if i complete username and password it its work, but i want to dont work, you know what i mean, must be complete all for be successful....and i dont know how to do it..help Link to comment Share on other sites More sharing options...
justsomeguy Posted November 27, 2007 Share Posted November 27, 2007 You could increment a variable and use mysql_num_rows() to check whether you are at the endYou can also just put the line breaks on every one and then use substr at the end to remove the last two characters.$string = substr($string, 0, -2); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.