I put the code into the tr tag on this line and the whole page stops giving an error message with this line number. Also when I put the code into the line the remaining tags don’t work
I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get bought an impatience over that you wish be delivering the following.
unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case
you shield this increase.
You can even replace “tr” with “div” and do it w/ classes!
The only problem in this example is that it will give a notice for the undefined variable $c.
What I usually do is first initialise the variable to 0 before the start of the loop. Then you won’t get the notice.
this code doesnt work.
sorry, i’m no good using the code tags..
i took out the ‘var’ before the $c = 0;
When I insert
this code, it renders it unuseable. Why would it work w/o but not with?
php var $c = 0;
The keyword “var” can only be used inside a class declaration.
$c = 0;
I think you confused it with the “var” keyword in JavaScript which initializes a variable.
You can also use the bitwise & to get odd and even.
eg:
<?php echo $c++&1 ? 'odd' : 'even'; ?>
Your example also has the odd and even switched around. Odd numbers will have $c++%2==1, not even.
Thanks bucabay!
Please can someone help?
I put the code into the tr tag on this line and the whole page stops giving an error message with this line number. Also when I put the code into the line the remaining tags don’t work
echo " \n£ $investment\n";
Thanks in anticipation
Cant understand, how it works…
Very handy and useful trick.
what about using array?
$class = array('even' => 'odd', 'odd' => 'even');
$curr = 'even';
<tr class="">
sorry, forgot the code wrapper
<tr class="”>
hmm still not working using pre or even code wrapper
anyway what i do is using $class[$curr] inside my loop
Can use this after the “While function”…
$bgcolor = ($bgcolor == “#ececec”) ? “#ffffff” : “#ececec”;
then…
print ”
bucabay, your code works!
zebra table
.even { background-color:#FFF; }
.odd { background-color:#666; }
<?php
for($a = 1;$a<=10;$a++)
{
echo "”;
echo “”;
echo “The no is $a”;
}
?>
genius script!!! thank you!
How do you maintain a consistent zebra pattern in a sortable PHP table?
You can use javascript.
Surprisingly simple. This works great. Thanks.
$bool = true;
for ($i = 1; $i <= 10; $i++) :
echo ‘<span class=”‘ . (($bool) ? ‘odd’ : ‘even’) . ‘”>’ . $i. ‘</span>’;
$bool = !$bool;
endfor;
This code is suitable for me. but i don’t know how to insert the css & where i can insert
Easy way to do it with JQuery
$(document).ready(function() {
$(“#tableid tr:even��).addClass(“stripe1”);
$(“#tableid tr:odd”).addClass(“stripe2”);
});
/* CSS
————- */
.stripe1 { background-color: # }
.stripe2 { background-color: # }
Thank you thank you thank you!
<?php
$class = "grey";
$rowCount = count($rows);
for ($i = 0; $i
<tr class="” >Data; ?>
I feel all code needs to be as readable as possible to eliminate as much need of inline comments as possible, even if the code may be slightly longer.
<?php
$class = "grey";
$rowCount = count($rows);
for ($i = 0; $i
<tr class="” >
For some reason my code was cut by the text parser. If this post doesn’t work, then I am sorry
I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get bought an impatience over that you wish be delivering the following.
unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case
you shield this increase.
$a=0;
while($row = mysql_fetch_assoc($udet))
{
if($a++%2==1)
{
echo “”.
“{$row[‘name’]} “.
“{$row[‘age’]} “.
“{$row[‘mobile’]} “.
“{$row[‘date’]} “.
“{$row[‘address’]} “;
}else{
echo “”.
“{$row[‘name’]} “.
“{$row[‘age’]} “.
“{$row[‘mobile’]} “.
“{$row[‘date’]} “.
“{$row[‘address’]} “;
}
}
perfect!
This code is very simple and yet works well. You are great, very good job! Thanks a lot!