Mysql hulp!

Gestart doorAllard9 reacties34 weergaven

10 berichten · pagina 1 van 1

Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste,

Ik heb even een vraag. Hoe kan ik als er staat in de database 1 of 2 of 3, dat hij er het volgende van maakt. Hij moet dat natuurlijk wel laten zien (echo).

1 = je broer
2 = je moeder
3 = je vader
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php

$q[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM tabel WHERE id="[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700])){[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kolomnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je broer[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]{[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kolomnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je moeder[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]{[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kolomnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je vader[/COLOR][COLOR= #007700];

}[/COLOR]

?>


Volgens mij kan het wel op deze manier, heb t niet getest dus weet het niet zeker!smile
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Voorbeeld klinkt beetje...

@jos

Kan ook uit array halen

$array[ nummer ]
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sorry, zie net dat mijn voorbeeld niet goed is, zal zo even kijken voor een andere manier.smile
EDIT:

Zo moet ie werken:

[COLOR= #0000BB]<?php

$q[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM tabel WHERE id="[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700]))[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kolomnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je broer[/COLOR][COLOR= #007700];

}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kolomnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je moeder[/COLOR][COLOR= #007700];

}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kolomnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je vader[/COLOR][COLOR= #007700];

}[/COLOR]

?>
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dank je, maar kan ik ook dat als het iets anders is dat er staat; Onbekend. Mijn script:

if($row[status] == 1){
   echo "<td style=color: #04B404;>Goedgekeurd</td>";
     }
  if($row[status] == 2){
   echo "<td style=color: #AEB404;>In behandeling</td>";
     }
  if($row[status] == 3){
   echo "<td style=color: #B40404;>Afgekeurd</td>";
     }
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #04B404;>Goedgekeurd</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]


  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]){[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #AEB404;>In behandeling</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]

  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #B40404;>Afgekeurd</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]

  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]2[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR] [COLOR= #FF8000]//of if($row[status] > 3){ hier de rest }[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #B40404;>Onbekend</td>"[/COLOR][COLOR= #007700];

}[/COLOR]

?>
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Josnl: It doesnt work?
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #04B404;>Goedgekeurd</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]


  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]){[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #AEB404;>In behandeling</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]

  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #B40404;>Afgekeurd</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]

   [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]status[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]){[/COLOR]

   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td style=color: #B40404;>Onbekend</td>"[/COLOR][COLOR= #007700];

     }[/COLOR]

?>


Ik weet niet welk nummer in je database de status onbekend moet geven, maar als je dat groter dan 3 doet komt het goed met de code die ik je heb gegeven.
0
Allard

Lid · Topicstarter

Berichten
970
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kan iemand me nog even helpen? Ik heb dit, maar ik wil dat els het er niets staat in de url. Dat er komt te staan: onbekend.

$order_by_action = $_GET["order_by"];
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]oder_by[/COLOR][COLOR= #007700]]))){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Leeg[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Iets[/COLOR][COLOR= #007700];

}[/COLOR]

?>
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