473,473 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

alter table row color determined by mysql order by query

27 New Member
hi,

have a mysql query that orders entry by complaint category.
this query is then used with mysql_fetch_array to generate table of records ordered by complaint and other parameters.
i can alter color for every even and odd row but how can i alter row color based on each specific 'ORDER BY' mysql query?
so how can i change color for every unique order of
Expand|Select|Wrap|Line Numbers
  1. $stat_rec['complaint'].
my code below:

[PHP]$sql=("SELECT a.month, b.location, c.complaint, d.source, e.number, f.stat_id, g.year
FROM month a, location b, complaint c, source d, stat e, stat f, year g
WHERE ('$_POST[m_id]' = e.m_id OR '$_POST[m_id]' = '')
AND ('$_POST[l_id]' = e.l_id OR '$_POST[l_id]' = '')
AND a.id_month = e.m_id
AND b.id_location = e.l_id
AND d.id_source = e.s_id
AND c.id_complaint = e.c_id
AND f.stat_id = e.stat_id
AND g.id_year = e.y_id
AND '$_POST[y_id]' = e.y_id
ORDER BY month,location,complaint,source") or die (mysql_error()) ;
IF (!mysql_query($sql,$con)) {die('Error: ' . mysql_error());}
//initializing extraction of customer stat
$CustomerStat = mysql_query($sql) or die (mysql_error());
[/PHP]

[PHP]while ($stat_rec= mysql_fetch_array($CustomerStat))
{ echo "<tr><td><a href=stat.php?stat_id=".$stat_rec['stat_id']."><p style = 'font-size:xx-small;'>".$stat_rec['stat_id']."</p></td>";
echo "<td>".$counter."</td>";
echo "<td>".$stat_rec['year']."</td>";
echo "<td>".$stat_rec['month']."</td>";
echo "<td>".$stat_rec['location']."</td>"; echo "<td>".$stat_rec['complaint']."</td>"; echo "<td>".$stat_rec['source']."</td>";
echo "<td>".$stat_rec['number']."</td></tr>";[/PHP]
Aug 28 '07 #1
1 2035
pbmods
5,821 Recognized Expert Expert
Heya, Prosad.

You posted this in the Articles section. I'll go ahead and move it to the Forum where an Expert will be more likely to find it.
Aug 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: | last post by:
As we're on this topic in another thread right now: Say I have a SELECT query from more than one table and with some = conditions, does it matter in what order I enter the tables in the FROM =...
0
by: Dan Edwards | last post by:
Hi about 2 months ago I had trouble with alter table on large tables blocking all database activity and started a thread on this list called "alter table blocks other tables!" I tried to resolve...
0
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
3
by: Michael Roedig | last post by:
I have a somewhat large table (abt 4 million records) and when I do an ALTER TABLE to add a column the database hangs. I have plenty of free disk space and memory. The server version is 4.0.17...
1
by: FRED | last post by:
hi all, i have a table that has a column date varchar(20) and now i learned some more about mysql I want to make it date date but if I do an alter table on it what will it do to my existing data...
0
by: anzenews | last post by:
Hello! I have a weird problem... The application I use issues this SQL from time to time: alter table t modify id int(6) unique not null auto_increment; The problem is that this SQL adds a...
1
by: boonkit | last post by:
I try to get better performance by implementing this: http://dev.mysql.com/doc/mysql/en/alter-table.html "ORDER BY allows you to create the new table with the rows in a specific order. Note...
2
by: terence.parker | last post by:
I am often faced with the dilemma of whether to use a JOIN query across three tables in order to grab a bunch of results - or whether to create another table to represent what I want. The latter is...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.