Bonjour all,
Comment faire une boucle :
for($i = 0; $i < 16; $i++)
Je suis pas très doué en php donc je demande l'avis des pros. Wink
Voici ce que j'ai :
C'est un exemple...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 $nomserver_1 = ( !empty($_POST['nomserver_1']) ) ? stripslashes(htmlspecialchars($_POST['nomserver_1'])) : ""; $nomserver_2 = ( !empty($_POST['nomserver_2']) ) ? stripslashes(htmlspecialchars($_POST['nomserver_2'])) : ""; $nomserver_3 = ( !empty($_POST['nomserver_3']) ) ? stripslashes(htmlspecialchars($_POST['nomserver_3'])) : ""; $nomserver_4 = ( !empty($_POST['nomserver_4']) ) ? stripslashes(htmlspecialchars($_POST['nomserver_4'])) : ""; $nomserver_5 = ( !empty($_POST['nomserver_5']) ) ? stripslashes(htmlspecialchars($_POST['nomserver_5'])) : ""; $ipserver_1 = ( !empty($_POST['ipserver_1']) ) ? stripslashes(htmlspecialchars($_POST['ipserver_1'])) : ""; $ipserver_2 = ( !empty($_POST['ipserver_2']) ) ? stripslashes(htmlspecialchars($_POST['ipserver_2'])) : ""; $ipserver_3 = ( !empty($_POST['ipserver_3']) ) ? stripslashes(htmlspecialchars($_POST['ipserver_3'])) : ""; $ipserver_4 = ( !empty($_POST['ipserver_4']) ) ? stripslashes(htmlspecialchars($_POST['ipserver_4'])) : ""; $ipserver_5 = ( !empty($_POST['ipserver_5']) ) ? stripslashes(htmlspecialchars($_POST['ipserver_5'])) : ""; $tickrateservpublic_1 = ( !empty($_POST['tickrateservpublic_1']) ) ? stripslashes(htmlspecialchars($_POST['tickrateservpublic_1'])) : ""; $tickrateservpublic_2 = ( !empty($_POST['tickrateservpublic_2']) ) ? stripslashes(htmlspecialchars($_POST['tickrateservpublic_2'])) : ""; $tickrateservpublic_3 = ( !empty($_POST['tickrateservpublic_3']) ) ? stripslashes(htmlspecialchars($_POST['tickrateservpublic_3'])) : ""; $tickrateservpublic_4 = ( !empty($_POST['tickrateservpublic_4']) ) ? stripslashes(htmlspecialchars($_POST['tickrateservpublic_4'])) : ""; $tickrateservpublic_5 = ( !empty($_POST['tickrateservpublic_5']) ) ? stripslashes(htmlspecialchars($_POST['tickrateservpublic_5'])) : ""; $slot_1 = ( !empty($_POST['slot_1']) ) ? stripslashes(htmlspecialchars($_POST['slot_1'])) : ""; $slot_2 = ( !empty($_POST['slot_2']) ) ? stripslashes(htmlspecialchars($_POST['slot_2'])) : ""; $slot_3 = ( !empty($_POST['slot_3']) ) ? stripslashes(htmlspecialchars($_POST['slot_3'])) : ""; $slot_4 = ( !empty($_POST['slot_4']) ) ? stripslashes(htmlspecialchars($_POST['slot_4'])) : ""; $slot_5 = ( !empty($_POST['slot_5']) ) ? stripslashes(htmlspecialchars($_POST['slot_5'])) : "";
J'ai essayé ceci :
mais problème dans la réponse, j'obtiens ca :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 for($i = 0; $i <= 6; $i++) { $nomserveur_num=$nomserveur.$i; $nomserver= ( !empty($_POST['$nomserveur_num']) ) ? stripslashes(htmlspecialchars($_POST['$nomserveur_num'])) : ""; $ipserver_num=$ipserver.$i; $ipserver= ( !empty($_POST['$ipserver_num']) ) ? stripslashes(htmlspecialchars($_POST['$ipserver_num'])) : ""; $tickrateservpublic_num=tickrateservpublic.$i; $tickrateservpublic= ( !empty($_POST['$tickrateservpublic_num']) ) ? stripslashes(htmlspecialchars($_POST['$tickrateservpublic_num'])) : ""; $slot_num=slot.$i; $slot= ( !empty($_POST['$slot_num']) ) ? stripslashes(htmlspecialchars($_POST['$slot_num'])) : ""; }
NOM DU/ DES SERVEUR(S)
---------------------------------------------------------------------------------
Nom du serveur N°: 0
Nom du serveur N°: 1
Nom du serveur N°: 2
Nom du serveur N°: 3
Nom du serveur N°: 4
Nom du serveur N°: 5
---------------------------------------------------------------------------------
IP DU/ DES SERVEUR(S)
---------------------------------------------------------------------------------
Nom du serveur N°: 0
Nom du serveur N°: 1
Nom du serveur N°: 2
Nom du serveur N°: 3
Nom du serveur N°: 4
Nom du serveur N°: 5
---------------------------------------------------------------------------------
Nbr DE SLOT DU / DES SERVEUR(S)
---------------------------------------------------------------------------------
Nom du serveur N°: 0
Nom du serveur N°: 1
Nom du serveur N°: 2
Nom du serveur N°: 3
Nom du serveur N°: 4
Nom du serveur N°: 5
---------------------------------------------------------------------------------
TICKRATE DU/ DES SERVEUR(S)
---------------------------------------------------------------------------------
Nom du serveur N°: 0
Nom du serveur N°: 1
Nom du serveur N°: 2
Nom du serveur N°: 3
Nom du serveur N°: 4
Nom du serveur N°: 5
Cordialement.
J'ai essayé mais je suis pas copain avec le php encore
Partager