0
1) i fetch data from database suppose $data contains all the data of table A

from $data first two goes to below div
<div> //bgcolor green     
echo $data['a'];
echo $data['a'];
</div>

next 2 data to below div
<div>//bgcolor yellow
echo $data['a'];
echo $data['a'];
</div>

again next two data to 
<div> //bgcolor green     
echo $data['a'];
echo $data['a'];
</div>

again next two data to 
<div>//bgcolor yellow
echo $data['a'];
echo $data['a'];
</div>

like this how to implement in php???

3
Contributors
2
Replies
18
Views
1 Year
Discussion Span
Last Post by diafol
1

PHP is an object oriented language based upon C++. It is most useful, and secure, when used that way. You save your HTML and JavaScript strings in class variables, and then output them when appropriate. DO NOT mix your HTML/JS code with PHP! That is a quick road to perdition.

Votes + Comments
Good advice
0

Keep html/php to a minimum. This is a bit rough, but you could do something like:

$cols = ['bgGreen','bgYellow','bgBlue']; //etc etc
$cnt = count($cols);
$i = 0;
$output = '';
foreach($data as $d){
    if($i == $cnt)$i=0;
    $output .= "\n<div class='$cols[$i]'>$d[0] $d[1]</div>";
    $i++;
}

Then...

echo $output;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.