Problem setting the row class
Problem setting the row class
nicolaesse
Posts: 1Questions: 0Answers: 0
Hi, I am using DataTables with PHP and MySQL with great results but I'm having lots of troubles setting up the classes of the row.
My SQL table have a column named "class_style" which contain some values like "blue_class", "green_class", "red_class", ...
My target is to declare this class name on every row of the results so I can (for example) show "red_class" rows with red background, something like this example http://www.datatables.net/release-datatables/examples/basic_init/zero_config.html where the are show in red.
The code I thought would work is the following:
[code]
echo "";
for($i=0; $i < $number_of_results; $i++){
echo "";;
echo "" . mysql_result($result, $i, 'family_name') . "";
echo "" . mysql_result($result, $i, 'team') . "";
echo "";
};
echo "";
[/code]
when I open the page with the browser each row of the table is being shown with the following class:
[code]
[/code]
Even if I use a less automatized solutions like the following
[code]
echo "";
for($i=0; $i < $number_of_results; $i++){
echo "";;
echo "" . mysql_result($result, $i, 'family_name') . "";
echo "" . mysql_result($result, $i, 'team') . "";
echo "";
};
echo "";
[/code]
all the classes became
[code]
[/code]
how could I get a solution of this problem? I'd like to reach the following results:
[code]
Smith
the Duck
Jackbson
Big great team
Awaiters
the flowers
[/code]
My SQL table have a column named "class_style" which contain some values like "blue_class", "green_class", "red_class", ...
My target is to declare this class name on every row of the results so I can (for example) show "red_class" rows with red background, something like this example http://www.datatables.net/release-datatables/examples/basic_init/zero_config.html where the are show in red.
The code I thought would work is the following:
[code]
echo "";
for($i=0; $i < $number_of_results; $i++){
echo "";;
echo "" . mysql_result($result, $i, 'family_name') . "";
echo "" . mysql_result($result, $i, 'team') . "";
echo "";
};
echo "";
[/code]
when I open the page with the browser each row of the table is being shown with the following class:
[code]
[/code]
Even if I use a less automatized solutions like the following
[code]
echo "";
for($i=0; $i < $number_of_results; $i++){
echo "";;
echo "" . mysql_result($result, $i, 'family_name') . "";
echo "" . mysql_result($result, $i, 'team') . "";
echo "";
};
echo "";
[/code]
all the classes became
[code]
[/code]
how could I get a solution of this problem? I'd like to reach the following results:
[code]
Smith
the Duck
Jackbson
Big great team
Awaiters
the flowers
[/code]
This discussion has been closed.