searls03 Posted March 22, 2011 Share Posted March 22, 2011 how can I basically put a horizontal rule between each entry on this code.......? <?php if (isset($_POST['submitted'])) { include('connect1.php'); $category = $_POST['category']; $criteria = $_POST['criteria'] ; $query = "SELECT * FROM members WHERE $category LIKE '%".$criteria."%'"; $result = mysqli_query($dbcon, $query) or die('error getting data'); $num_rows = mysqli_num_rows($result); echo "$num_rows results found"; echo "<table width=\"896\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr bgcolor=\"#F7E496\"><td bgcolor=\"#F7E496\"><strong>User ID</strong></td> <td bgcolor=\"#F7E496\"><strong>Name</strong></td> <td bgcolor=\"#F7E496\"><strong>email</strong></td> <td bgcolor=\"#F7E496\"><strong>City</strong></td><td bgclor=\"#F7E496\"></td></tr>"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr><td>"; echo $row['userid']; echo "</td><td>"; echo $row['name']; echo "</td><td>"; echo $row['email']; echo "</td><td>"; echo $row['city']; echo "</td><td>"; echo "<form action='admin.php' method='get'><input type='hidden' name='edit'><input type='hidden' name='id' value='{$row['userid']}'><INPUT TYPE='submit' name='submit' VALUE='Edit'></form>\n"; echo "</td><td>"; echo "<form action='delete_account.php' method='get'><input type='hidden' name='userid' value='{$row['userid']}'><INPUT TYPE='submit' name='submit' VALUE='Delete'></form>\n"; echo "</td></tr>"; } echo "</table>"; } ?> basically each time the code is shown is an entry...... Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/ Share on other sites More sharing options...
aabid Posted March 22, 2011 Share Posted March 22, 2011 Following thread will help you to achieve what you want, just go through it http://www.phpfreaks.com/forums/index.php?topic=178959.msg796808 Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1190715 Share on other sites More sharing options...
searls03 Posted March 22, 2011 Author Share Posted March 22, 2011 something even better I would like to try is to make every other result row a different color......... Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1190720 Share on other sites More sharing options...
aabid Posted March 22, 2011 Share Posted March 22, 2011 something even better I would like to try is to make every other result row a different color......... That's looking creative one, Never thought about it before. Will put your logic next time I will meet with these sort of things Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1190721 Share on other sites More sharing options...
kenrbnsn Posted March 22, 2011 Share Posted March 22, 2011 This is a generalized way of alternating colors: <?php $color = 'white'; //starting color $x = 0; $testing = 'the quick brown fox jumped over the lazy dog'; while ($x < 10) { echo "<span style='color:$color'>$testing</span><br>"; $color = ($color == 'white')?'grey':'white'; $x++; } ?> Now just adapt this code to your code... Ken Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1190723 Share on other sites More sharing options...
searls03 Posted March 23, 2011 Author Share Posted March 23, 2011 This is a generalized way of alternating colors: <?php $color = 'white'; //starting color $x = 0; $testing = 'the quick brown fox jumped over the lazy dog'; while ($x < 10) { echo "<span style='color:$color'>$testing</span><br>"; $color = ($color == 'white')?'grey':'white'; $x++; } ?> Now just adapt this code to your code... Ken ok so where would I put what from my query? Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1191461 Share on other sites More sharing options...
searls03 Posted March 28, 2011 Author Share Posted March 28, 2011 as in where would I put certain parts of my query to make these different colors? Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1193404 Share on other sites More sharing options...
sasa Posted March 28, 2011 Share Posted March 28, 2011 <?php $color = 'white'; //before your while loop $x = 0; //not need $testing = 'the quick brown fox jumped over the lazy dog';//not need while ($x < 10) { echo "<span style='color:$color'>$testing</span><br>"; //inside your while loop //add style='background-color:$color;' // to <tr> tag $color = ($color == 'white')?'grey':'white';//inside while loop $x++;//not need } ?> Quote Link to comment https://forums.phpfreaks.com/topic/231361-horizontal-rule/#findComment-1193416 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.