Jump to content

** Resolved ** Alternating row colors?


alexcmm

Recommended Posts

What's the easiest way to get alternating row colors? My code is very simple and I'm not sure if I can throw it in with ease or if I'll have some major overhauling to do... here's my code now. Thanks for your help.

[b]<?

include 'dbinfo.php';

MYSQL_CONNECT(localhost, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$database") or die( "Unable to select database");

$query="SELECT * FROM $usertable ".stripslashes($mainreport)." ".stripslashes($sortby)."";
$result=mysql_query($query);
$num=mysql_numrows($result);

$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$UserName=mysql_result($result,$i,"UserName");
$AccessLevel=mysql_result($result,$i,"AccessLevel");
$status=mysql_result($result,$i,"status");
$attending=mysql_result($result,$i,"attending");
$prefix=mysql_result($result,$i,"prefix");
$firstname=mysql_result($result,$i,"firstname");
$initial=mysql_result($result,$i,"initial");
$lastname=mysql_result($result,$i,"lastname");

echo
?>[/b]
Link to comment
Share on other sites

aah... i remember making my pages like that... untill i found the wonder of mysql_fetch_array();

[code]
<?

include 'dbinfo.php';

MYSQL_CONNECT(localhost, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$database") or die( "Unable to select database");

$query="SELECT * FROM $usertable ".stripslashes($mainreport)." ".stripslashes($sortby)."";
$result=mysql_query($query);

while($row=mysql_fetch_array){
echo $row[id];
echo $row[UserName];
echo $row[AccessLevel];
echo $row[status];
echo $row[attending];
echo $row[prefix];
echo $row[firstname];
echo $row[initial];
echo $row[lastname];
}
?>
[/code]

thats much faster, and easier on your database... also causes less problems in the long run :-)
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.