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 3348 Atli 5,058
Recognized Expert Expert
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
Recognized Expert Expert
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 ;)
pbmods 5,821
Recognized Expert Expert
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.
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 bgcolor="blue">,
otherwise, don't do anything, and it will output colors in alternate
rows. I tried to use count, but doesn't work.
Any ideas? Please advise.
<xsl:for-each select="/authors/author">
|
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 to alternate
shade a form???
Private Sub Alternate_Detail_Format(Cancel As Integer, FormatCount As
Integer)
Const vbLightGrey = 12632256
|
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 unable to alternate the colour of every row so that the table
is lot more readable. can anyone suggest a javascript or even a css
script which will alternate the row colours irrespective of the number
of rows.
|
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 its a lot more easier to read. i have tried to implement
a few approaches but everytime it fails.
can somebody help me out with us and suggest a solution.
thanks.
|
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 with another color. Also created
a class called "Selected". You can only select a row at a time.
My problem is, if a row is preselected, when mouseover the selected
row, the selected color is screwed. Until you click on the selected row
once, the...
| |
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 Page.
With Expecting Result,
Sam
|
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.
ex.
<table>
<tr> <td>a</td><td>1</td> </tr>
<tr> <td>b</td><td>2</td> </tr>
|
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, I have no problem generating the table. What is the proper way to do this?
=====================
// Table header.
echo '<table align="center" cellspacing="0" cellpadding="5" border="0">
<tr>
<td align="left"><strong>Edit</strong></td>...
|
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 and select the first color.
.ControlSouce =fRowNum(False)
.Name = RowNum
2nd step: Add the following function to the form module: (for row numbers)
Public Function fRowNum(Reset As Boolean) As Long
Static I As Integer
|
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 result of the query in a table. I would like some help with the code to colour the alternate rows please.
function printQuery($param)
{
echo "<table width=100% valign=center>";
echo "<tr>"; foreach ($param as $key => $result)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |