$value != NULL can not leave for other reasons that wil take way to long to explain. What I need to do is say if the name=\"host$i\" was NULL on its last loop the don't show name=\"name$i\. Furthermore I need to say if name=\"name$i\ is going to be NULL on the next loop then don't show name=\"host$i\ on this time through the loop.
Confusing huh! Well maybe the form will help you understand...
http://www.nirus.net/temp/serverstat/index.php
to view the form I am talking about, click on change hosts at the bottom after clicking on launch serverstat.
if you want to see the entire script (not too long) then go here:
http://www.nirus.net/temp/serverstat/inc/script.txt
Code: Select all
//make an empty array to hold the csv values
$hostnamels = array();
//open the csv file and insert it into an array
$hosts = fopen("../dat/hosts.dat", "r");
while (($hostsdat = fgetcsv($hosts, 150, "|")) !== FALSE) {
array_push($hostnamels , $hostsdatї0], $hostsdatї1]);
}
fclose($hosts);
// show the array on an input form
$step = 1;
$i = 1;
foreach($hostnamels as $value) {
//The mod 2 controls whether to insert the current value in the name or host column
if ($step % 2 == "1" && $value != NULL){
print "<tr><td><input name="host$i" value="$value"></td>";
}
else if($step % 2 != "1" && $value != NULL){
print "<td><input name="name$i" value="$value"></td></tr>";
$i++;
}
$step++;
}
// add an input to add a new host
echo "<tr><td><input name="addhost1" value=""></td>";
echo "<td><input name="addname1" value=""></td></tr>";