[ethernet] making a table with 'for' function

hi guys
i’m still struggling with my arduino+ethernet programming codes
i’m trying make a table like this on my webserver project :

| Sensor 1| Off | LED 1| Off |
| Sensor 2| Off | LED 2| Off |
| Sensor 3| Off | LED 3| Off |
| Sensor 4| Off | LED 4| Off |

i tried “for” function in my codes… but it still doesnt work
here is my code :

client.println("");
for (int i=1;i<=4;i++){
client.println(");
clint.println(“”);
client.println("");
}
client.println("

Sensor (+i+) Off LED (i) OFF
");

the result is :

| Sensor (+i+)| Off | LED (+i+)| Off |
| Sensor (+i+)| Off | LED (+i+)| Off |
| Sensor (+i+)| Off | LED (+i+)| Off |
| Sensor (+i+)| Off | LED (+i+)| Off |

i dont know how to turn “(+i+)” into 1,2,3,4
please help me, i’m a newbie
thanks

i dont know how to turn "(+i+)" into 1,2,3,4

The sprintf() function is your friend.

for (int i=1;i<=4;I++i){

?

how about:

client.println("<table>");
for (int i=1;i<=4;i++){
client.println(<tr>");
client.print("<td>Sensor "); //changed
client.print(i); //added
client.println(" </td><td> Off </td><td>LED (i)</td><td>OFF</td>");//changed
client.println("</tr>");
}
client.println("<table>");

Although you’ll eventually need something like:

int sensor[4]; //to fill with readings
char OnOff [][] = {"OFF", "ON"};
char sensorStatus[4];

....
client.println("<table>");
for (int i=1;i<=4;i++){
client.println(<tr>");
client.print("<td>Sensor "); //changed
client.print(i); //added
client.print(" </td><td> ");
client.print(OnOff[sensorStatus[i]]);
client.print(" </td><td> LED ");
client.print(i);
client.print("</td><td> ");
client.print(OnOff[LEDStatus[i]]);
client.println(" </td>");
client.println("</tr>");
}
client.println("<table>");

so sprintf is really the way to go. :wink:

wow thanks for the responses really help me a lot