Can anyone show me psychic powers in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nirus
Forum Newbie
Posts: 16
Joined: Fri Dec 17, 2004 12:35 am
Location: Iowa

Can anyone show me psychic powers in php

Post by nirus »

This is way to hard to explain but here are the rules for solving this...
$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>";
               &#125;
   else if($step % 2 != "1" && $value != NULL)&#123;
         print "<td><input name="name$i" value="$value"></td></tr>";
         $i++;
        &#125;
   $step++;
&#125;
// add an input to add a new host
echo "<tr><td><input name="addhost1" value=""></td>";
echo "<td><input name="addname1" value=""></td></tr>";
-Nirus
Post Reply