Jump to content

horizontal rule


searls03

Recommended Posts

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......

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

<?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
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.