alter table row color determined by mysql order by query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prosad
    New Member
    • Jul 2007
    • 27

    alter table row color determined by mysql order by query

    hi,

    have a mysql query that orders entry by complaint category.
    this query is then used with mysql_fetch_arr ay 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
    [CODE=php]$stat_rec['complaint'].[/CODE]

    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,sourc e") or die (mysql_error()) ;
    IF (!mysql_query($ sql,$con)) {die('Error: ' . mysql_error()); }
    //initializing extraction of customer stat
    $CustomerStat = mysql_query($sq l) or die (mysql_error()) ;
    [/PHP]

    [PHP]while ($stat_rec= mysql_fetch_arr ay($CustomerSta t))
    { echo "<tr><td><a href=stat.php?s tat_id=".$stat_ rec['stat_id']."><p style = 'font-size:xx-small;'>".$stat _rec['stat_id']."</p></td>";
    echo "<td>".$counter ."</td>";
    echo "<td>".$stat_re c['year']."</td>";
    echo "<td>".$stat_re c['month']."</td>";
    echo "<td>".$stat_re c['location']."</td>"; echo "<td>".$stat_re c['complaint']."</td>"; echo "<td>".$stat_re c['source']."</td>";
    echo "<td>".$stat_re c['number']."</td></tr>";[/PHP]
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    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.

    Comment

    Working...