MySQL record waarde -> bepaald kleur v tekst

Gestart doorTherichg0 reacties48 weergaven

1 berichten · pagina 1 van 1

Therichg

Lid · Topicstarter

Berichten
676
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey

Ik heb dus een systeempje, en dat toont alles wat er in de bepaalde tabel (floors) staat.
Hiervoor heb ik deze code gemaakt:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]////HIERBOVEN STAAT NOG DE DATABASEVERBINDING, DIT STAAT HIER NIET BIJ.//////[/COLOR]
[COLOR= #0000BB]$query[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * from floors"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"<table border=0>"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$aantalvelden[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_fields"]mysql_num_fields[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]<[/COLOR][COLOR= #0000BB]$aantalvelden[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]++) {[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"<th>"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_field_name"]mysql_field_name[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]"</th>"[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700],[/COLOR]MYSQL_ASSOC[COLOR= #007700])) {[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"<tr>"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$veldwaarde[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"<td>$veldwaarde</td>"[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"</tr>"[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700]);[/COLOR]


De tabel heeft 2 rijen: "floornr" & "status"
In de rij status is het de bedoeling dat als er een record voorkomt met "onvoltooid" als status, dat dat dan in die pagina rood wordt, en als er "voltooid" staat bij status, dat het dan in groen staat.

Hoe doe ik dit?

Mvg
Therichg
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren