Hi, I need to do some text file manipulation of a text file from an html interface. I have a file with multiple lines where each line has 2 fields each (a mac address and an associated vlan). Here's an example of rht text file:
/tmp/TEST: ==================== a1b2.c3d4.e5cc VLAN3 a1b2.c3d4.e5dd VLAN4 a1b2.c3d4.e5ee IS a1b2.c3d4.e5ff VLAN6 a1b2.c3d4.e5a1 VLAN7 a1b2.c3d4.e5b2 VLAN8 a1b2.c3d4.e5c3 Printer a1b2.c3d4.e5d4 Guest a1b2.c3d4.e5e5 IS a1b2.c3d4.e5f6 VLAN6 a1b2.c3d4.e5a2 VLAN2 a1b2.c3d4.e5a3 VLAN4 ==================== Being an admin and not a developer of any kind, I'm having trouble reading in the file and being able to output specific lines and fields of a php array. This is what I have so far: ==================================================== <HTML> <HEAD> <TITLE>MAC address Listing</TITLE> </HEAD> <BODY> <?php $CnfRec=array(); $CnfRec=file("/tmp/TEST"); foreach ($CnfRec as $line) { $CnfRec=explode(" ",$line); echo "LINE: "; print_r($line); echo " CnfRec: "; print_r($CnfRec); echo "<P>"; }; ?> </BODY> </HTML> ==================================================== What I want to eventually do is read in the "records" and fields of this file, present it as a form, allow admins to modify the second field and write that back to the text file (while backing up the original file). As a reference, I handle it in a completely different way, but this is how I'd kinds like things to look visually ( just one "submit" button would be preferable): ========================================================================== <HTML> <HEAD> <TITLE>MAC address listing</TITLE> </HEAD> <BODY> <?php echo "<table border='1' align=center>\n"; echo "<tr BGCOLOR='#99CCFF'><th width=150>MAC Address</th><th width=150>VLAN</th></tr>"; $res = system("/bin/sort -k 1 /tmp/TEST | /bin/awk '{ print \"<tr align='center'><td>\"$1\"</td><td><FORM METHOD=POST ACTION='/cgi-bin/change_mac-vlan_list.sh'><SELECT NAME='VLAN'> <OPTION SELECTED VALUE='\"$2\"'>\"$2\"</OPTION> <OPTION VALUE='VLAN0002'>VLAN2</OPTION> <OPTION VALUE='VLAN0003'>VLAN3</OPTION> <OPTION VALUE='VLAN0004'>VLAN4</OPTION> <OPTION VALUE='IS'>IS</OPTION> <OPTION VALUE='VLAN0006'>VLAN6</OPTION> <OPTION VALUE='VLAN0007'>VLAN7</OPTION> <OPTION VALUE='VLAN0008'>VLAN8</OPTION> <OPTION VALUE='Printer_VLAN'>Printers</OPTION> <OPTION VALUE='Guest'>Guest</OPTION></SELECT><INPUT TYPE='SUBMIT' VALUE='Change'></FORM></td></tr>\" }' "); ?> </BODY> </HTML> ========================================================================== TIA, Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php