hey everyone,
I'm transforming my site to be database driven website for better and faster modification since it uses HTML for the moment.
My quetion is,
I have a control panel where I can control the tables of the site, some sections, edit the css...
there is a section on my site where a table has to be created to display some info with specs for the user [hosting plans]
let's take this exmple
Plan Name
Space
Bandwidth
POP3
FTP
MySQL
...
now from my control panel, i want to add:
plan 1
1 Gb
yes / or image [tick]
yes / or image
no / or image [x]
the question is as shown in the title,
I want that every row of the table to be altered from the row coming after it
so the first row will be white, the second will be gray, it will get the colors from a css file.
and I want the table header to be color fixed differnet from the rows, i.e blue
any help would be really appreciated
thanks in advance
12 3293 Atli 5,058
Expert 4TB
Hi. Welcome to The Scripts!
So basically what you are trying to do is paint the background of every other row differently from the one above it? That is to say; odd row numbers one color and even numbers another?
If so then the first thing we need to know, what type of server-side script are you using? PHP? ASP? etc...
Are you perhaps planing on doing this in JavaScript?
And is there any particular reason why you posted this in a MySQL forum?
hey Atli,
this is what i want, even rows color is different than the odd ones.
I'm using PHP/MySQL
Is there any else method other than the javascript one ?
I posted in the MySQL forum for the reason shown below:
I'm transforming my site to be database driven website for better and faster modification since it uses HTML for the moment.
which i thought that the answer for my question, can be found here, where MySQL experts are
regards
Atli 5,058
Expert 4TB
OK I see.
In the much popular PHP/MySQL duo, the actual coding is done in PHP. MySQL is mostly just a data storage, the database which PHP uses to store data in.
So, to solve your problem, you would need a PHP code. Something similar to this: -
<?php
-
# Print the start of the table.
-
echo "\n<table>";
-
-
# Loop throught while $i is less than 10
-
# each time incrementing $i by one.
-
for($i = 0; $i < 10; $i++)
-
{
-
# $i % 2 divides the number $i by 2 and returns the rest (0 or 1)
-
# which I then add one to, so this will alwasy be either 1 or 2
-
$color = "color". ($i % 2 + 1);
-
-
# Print a row into the table.
-
echo "\n\t<tr><td class=\"$color\">Row $i</td></tr>";
-
}
-
-
# Print the end of the table.
-
echo "\n</table>";
-
?>
Now this code assumes that there are CSS classes called "color1" and "color2" that contain the color.
You will obviously need to adapt this to your own code, but you can see where I am going with this.
thank you for your reply,
The code works perfectly ;)
Moving to the HTML/CSS forum.
Or:
.even{
background-color:blue
}
.odd{
background-color:yellow
}
<tr class="even">
<tr class="odd">
I'm aware of that article but forgot about his css selector solution.
Heya, TheGenius.
Is that what they're calling me? I'll have to find this "they" person and shoot him.
Is that what they're calling me? I'll have to find this "they" person and shoot him.
The OP's nick is 'thegenius', and I embellished it a bit with some fancy capitals.
But we all like to think of you as "theGenius". 0:)
Does it pay more? .
It pays 500% what you're getting for it now!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt |
last post by:
I want to produce colors in alternate rows in the table.
The following will produce blue color on every row. So my problem is to figure
out to count the records. If it is odd record, then do <tr...
|
by: jeffgeorge |
last post by:
Using a bit of code to produce alternate line shading in a report.
Seems it should work for a form as well but no luck. Does anyone have
any ideas what I need to change or if it is even possible...
|
by: sconeek |
last post by:
Hi all,
I am generating a html based table with multiple rows of data coming
in real time from a postgres DB. The underlying technology is java
based however the front end is html.
now i am...
|
by: sconeek |
last post by:
hi all,
my java servlet code has a foreach loop which automatically generates a
HTML table with x number of rows.
now my problem is that I would like the rows to be alternating in
colour so that...
|
by: Amy |
last post by:
I need some help.
I have this table with alternate row colors. Class gray and class
white. I have javascript that do highlight when mouseover row ... and
onclick to select row and highlight it...
|
by: samuel saravanan |
last post by:
Hai To All ,
Could U Plz Tell Me Asp Coding To Create A Table But With Alternate Coloured Rows, And Also Tell Me Some Of Techniques To Positioning The Table At Right Place In A Web...
|
by: pradheepayyanar |
last post by:
Dear All
i have dynamic generation of <table>
rt now i have done the <TR> with alternate colors which is a dynamic table.
my requirement is that for every cumulative <tr> i need different color....
|
by: pixelnate |
last post by:
I am trying to use a CSS class called "evens" to color the background of alternate rows of a dynamic table. The foreach statement is preventing the data from being displayed at all. If I take it out,...
|
by: Michael R |
last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form.
1st step: Create a textbox, send it to background...
|
by: JohnDriver |
last post by:
Hi,
I am happy to say that with your help, I have been performing good in Ajax. Thanks for helping me to start with. I have a small problem now. I am pulling records from database and passing...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |