Page 1 of 1

counter function in hidden value name??

Posted: Wed Nov 12, 2008 5:27 am
by ganza

Code: Select all

 
         foreach($list as $record)
    {
        echo "<tr>\r\n";
        echo "  <td>".$record['personIncharge']."\r\n";
        echo "  <input type='submit' name='EditPIC' value='edit'></td>\r\n";
        echo "  <input type='hidden' value=".$record['contact_ID']." name="uiuaa">\r\n";
        echo "  <td>".$record['designation']."</td>\r\n";
        echo "  <td>".$record['department']."</td>\r\n";
        echo "  <td>".$record['mainLine']."</td>\r\n";
        echo "  <td>".$record['faxLine']."</td>\r\n";
        echo "  <td>".$record['directLine']."</td>\r\n";
        echo "  <td>".$record['mobile']."</td>\r\n";
        echo "  <td><a href='deleteRow.php?id=".$record["contact_ID"]."'>Delete</a></td>\r\n";
        echo "</tr>\r\n"; 
    }
    echo "</table>\r\n";
}
 
is it possible for me to add a counter command in hidden value name?
so i mean it will give different name each line (0001uiuaa)
the second line will be (0002uiuaa) etc ...
is it possible?

Re: counter function in hidden value name??

Posted: Wed Nov 12, 2008 8:02 am
by watson516

Code: Select all

 
$count=1;
         foreach($list as $record)
    {
        echo "<tr>\r\n";
        echo "  <td>".$record['personIncharge']."\r\n";
        echo "  <input type='submit' name='EditPIC' value='edit'></td>\r\n";
        echo "  <input type='hidden' value=".$record['contact_ID']." name='".$count."uiuaa'>\r\n";
        echo "  <td>".$record['designation']."</td>\r\n";
        echo "  <td>".$record['department']."</td>\r\n";
        echo "  <td>".$record['mainLine']."</td>\r\n";
        echo "  <td>".$record['faxLine']."</td>\r\n";
        echo "  <td>".$record['directLine']."</td>\r\n";
        echo "  <td>".$record['mobile']."</td>\r\n";
        echo "  <td><a href='deleteRow.php?id=".$record["contact_ID"]."'>Delete</a></td>\r\n";
        echo "</tr>\r\n"; 
        $count++;
    }
    echo "</table>\r\n";
}
 
Something like that I would think no?