PHP - Reading .txt Files & Manipulating Its Data For Output
trying to create a simpleprogram that will read a text file and output information and calculations using the data in the text file. I have 4 radio buttons which represent an item Number. when one is selected the output form should print to a table the ID,Part,Count, Price, and the inventory Value= ($count * $price), can anyone tell me what i am doing wrong?
This is what the .txt file looks like: AC1000:Hammers:122:12.50 AC1001:Wrenches:5:5.00 AC1002:Handsaws:10:10.00 AC1003:Screwdrivers:222:3.00 Here's what i have so far: Code: [Select] <?php $inf = 'infile.txt'; $FILEH = fopen($inf, 'r') or die ("Cannot open $inf"); $inline = fgets($FILEH,4096); $found = 0; //$ptno = //if (isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000'])) { while (!feof($FILEH) && !($found)){ list($ptno,$ptname,$num,$price) = split (':', $inline); if ($ptno == $id) { print '<table border=1>'; print '<th> ID <th> Part <th> Count <th> Price'; print "<tr><td> $ptno </td><td>$ptname</td>"; print "<td> $num </td><td> \$price</td><tr>"; print '</table>'; $found = 1; } $inline = fgets($FILEH,4096); } if ($found !=1) { print "Error: PartNo=$id not found"; } fclose ($FILEH); ?> Similar TutorialsHi, Given below is the output of a field from a mySQL/php query: Product ID: 8457, Product Qty: 3, Product SKU: M-242, Product Name: DCE/DTE DB60 Crossover Cable - 1FT, Product Weight: 1, Product Variation Details: , Product Unit Price: 4.68, Product Total Price: 14.04|Product ID: 8800, Product Qty: 1, Product SKU: M-1038, Product Name: RJ45 8P8C Plug Flat Stranded 50pcs/Bag, Product Weight: 1, Product Variation Details: , Product Unit Price: 3.42, Product Total Price: 3.42|Product ID: 8940, Product Qty: 1, Product SKU: M-1385, Product Name: RJ11/12/45 Crimp Tool with Ratchet [HT-568R], Product Weight: 1, Product Variation Details: , Product Unit Price: 9.89, Product Total Price: 9.89 How can I add a <br> before every occurance of the term "Product" (without quotes). That would make the output legible. Should it be done client side, or server side. I can use help for both. Thanks in advance What I'm basically doing is grabbing data from a source and I want to display it in a different way. A preview of the original data is below: Code: [Select] CODED SURFACE FRONTAL POSITIONS NWS HYDROMETEOROLOGICAL PREDICTION CENTER CAMP SPRINGS MD 626 PM EDT WED NOV 03 2010 VALID 110321Z HIGHS 1022 4120673 1028 6431205 1037 5121174 1022 7090423 1038 4801098 1030 7571450 1022 3471278 1034 4051133 LOWS 993 5320344 966 5391454 997 6230330 999 5240802 1010 3420760 983 6500819 1005 4610855 1006 2940904 OCFNT 2940905 2960901 2980896 2990888 STNRY 3420761 3320775 3250786 3120797 3060803 2990809 2960827 2960845 2980865 3000875 WARM 2990890 3000884 3000874 COLD 2990889 2920886 2860886 2740887 2550890 2300898 2050915 1900925 1790928 TROF 3370890 3230894 3150899 3030905 2960905 OCFNT 5350359 5450351 5510329 5500297 5430258 OCFNT 5381446 5311448 5301459 5351468 5441476 5551479 5631473 5681464 WARM 5681463 5741440 5751407 5641362 COLD 5681464 5651448 5571426 5411395 5101369 4621361 4181372 3911400 WARM 5240803 5260801 5300797 WARM 3420760 3370753 3220744 3110732 COLD 6310816 6070824 5710847 5390887 5260940 5331010 5471037 5701058 STNRY 5691057 5791069 5931103 6061141 6101175 6101228 6211269 6261311 6171372 OCFNT 6480822 6540806 6550778 6500744 6400726 6320724 COLD 6320724 6190730 6010743 5650771 5470785 5300798 WARM 6330724 6200704 5830682 COLD 5240803 5090814 4840835 4740842 4660850 WARM 4600857 4630853 4670849 TROF 5400425 5190425 5030426 COLD 4590856 4510867 4390888 4330920 TROF 4490863 4290871 4110884 TROF 4280784 4190795 4140809 4080821 4050830 3980846 3870859 3780871 TROF 6190558 5990522 5680487 5520465 5480454 TROF 6790829 7110827 7470810 7810750 TROF 4511195 4621185 4751161 4831138 TROF 5891623 6091652 6331660 6571662 6781674 6961718 $$ I will take a few lines from that and explain what I'd like to do. Code: [Select] HIGHS 1022 4120673 1028 6431205 1037 5121174 1022 7090423 1038 4801098 1030 7571450 1022 3471278 1034 4051133 I would like to pull the "1022" (MB) and "4120673" (LAT/LON), then "1028" (MB) and "6431205" (LAT/LON), etc. and display them like this: Code: [Select] Icon: 41.2, -67.3,000,1,1,1022 Icon: 64.3, -120.5,000,1,1,1028 Basically: Icon: LAT, LON,000,1,1,MB "LOWS" would be displayed the same way as "HIGHS" above. "WARM", "COLD", "STNRY", "OCFNT", and "TROF" would be displayed differently as you can see the data for these is different. Those would be displayed like this: From: Code: [Select] COLD 5681464 5651448 5571426 5411395 5101369 4621361 4181372 3911400 To: Code: [Select] Line: 3,0,"Cold Front" 56.8, -146.4 56.5, -144.8 55.7, -142.6 54.1, -139.5 51.0, -136.9 46.2, -136.1 41.8, -137.2 39.1, -140.0 End: For a better understanding of what this data represents you can visit this website. They explain everything nicely. I'm playing around with "explode" at the moment but I'm clueless as the direction to go to achieve all these different things. Any help will be greatly appreciated. What I need is to: - take the information from array 1 - remove it from array 2 - then ADD it OR take from array 3 (this of course depends on array 1) I also have to keep in mind that array 1 could be empty thus needing to empty array 2 and IF the information is in array 3 then remove it array 3 is the main array that I will update the database row which will in turn display the correct check boxes checked or not Thank you for reading, I hope you can help me. Code: [Select] Array //#1 this is the submitted information ( [0] => 103100000 [1] => 103200000 [2] => 103400000 [3] => 103500000 [4] => 103700000 ) Array //#2 all possible choices ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) Array //#3 currently stored in database / marks the check boxes "checked" ( [0] => 103100000 [1] => 103200000 [2] => 103300000 [3] => 103400000 [4] => 103500000 [5] => 103600000 [6] => 103700000 ) this outputs but I need the corresponding subfields tied next to the =tags thanks for some ideas? <?php $doc = new DOMDocument(); $doc->load( 'loc.xml' ); $librecords = $doc->getElementsByTagName( "record" ); foreach( $librecords as $record ){ $leader = $record->getElementsByTagName( "leader" ); $controlfields = $record->getElementsByTagName( "controlfield" ); $datafields = $record->getElementsByTagName( "datafield" ); $subfields = $record->getElementsByTagName( "subfield" ); $leader = $leader->item(0)->nodeValue; echo '=LDR '.$leader.'<BR>'; foreach( $controlfields as $controlfield ){ $tag = $controlfield->getAttribute('tag'); $cf_value = $controlfield->firstChild->nodeValue; echo "=".$tag." ".$cf_value.'<BR>'; } foreach( $datafields as $datafield ){ $tag = $datafield->getAttribute('tag'); $ind1 = $datafield->getAttribute('ind1'); $ind2 = $datafield->getAttribute('ind2'); if ($ind1 ==" ") {$ind1 = "_";} if ($ind2 ==" ") {$ind2 = "_";} echo "=".$tag." ".$ind1.$ind2; echo '<BR>'; } foreach( $subfields as $subfield ){ $code = $subfield->getAttribute('code'); $sf_value = $subfield->firstChild->nodeValue; echo '$'.$code.$sf_value.'<BR>'; } echo '<BR><BR>'; } ?> here is the xml file, I called it loc.xml Code: [Select] <?xml version="1.0"?> <zs:searchRetrieveResponse xmlns:zs="http://www.loc.gov/zing/srw/"><zs:version>1.1</zs:version><zs:numberOfRecords>2144</zs:numberOfRecords><zs:records><zs:record><zs:recordSchema>info:srw/schema/1/marcxml-v1.1</zs:recordSchema><zs:recordPacking>xml</zs:recordPacking><zs:recordData><record xmlns="http://www.loc.gov/MARC21/slim"> <leader>01026ngm a22002773a 4500</leader> <controlfield tag="001">16429180</controlfield> <controlfield tag="005">20100823131409.0</controlfield> <controlfield tag="007">vffcjaho|</controlfield> <controlfield tag="008">100823s2010 xxu060 mleng </controlfield> <datafield tag="906" ind1=" " ind2=" "> <subfield code="a">0</subfield> <subfield code="b">cbc</subfield> <subfield code="c">orignew</subfield> <subfield code="d">u</subfield> <subfield code="e">ncip</subfield> <subfield code="f">20</subfield> <subfield code="g">y-movingim</subfield> </datafield> <datafield tag="955" ind1=" " ind2=" "> <subfield code="b">qm12 2010-08-23</subfield> </datafield> <datafield tag="010" ind1=" " ind2=" "> <subfield code="a"> 2010608899</subfield> </datafield> <datafield tag="017" ind1=" " ind2=" "> <subfield code="a">PA0001684303</subfield> <subfield code="b">U.S. Copyright Office</subfield> </datafield> <datafield tag="040" ind1=" " ind2=" "> <subfield code="a">DLC</subfield> <subfield code="c">DLC</subfield> <subfield code="e">amim</subfield> </datafield> <datafield tag="050" ind1="0" ind2="0"> <subfield code="a">VBU 4599 (viewing copy)</subfield> </datafield> <datafield tag="245" ind1="0" ind2="0"> <subfield code="a">30 Rock.</subfield> <subfield code="p">Emmanuelle goes to Dinosaur Land.</subfield> </datafield> <datafield tag="246" ind1="3" ind2="0"> <subfield code="a">Emmanuelle goes to Dinosaur Land</subfield> </datafield> <datafield tag="246" ind1="3" ind2=" "> <subfield code="a">Thirty rock.</subfield> <subfield code="p">Emmanuelle goes to Dinosaur Land</subfield> </datafield> <datafield tag="257" ind1=" " ind2=" "> <subfield code="a">United States.</subfield> </datafield> <datafield tag="260" ind1=" " ind2=" "> <subfield code="c">2010-05-13.</subfield> </datafield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">1 videocassette of 1 (Betacam SP) (60 min.) :</subfield> <subfield code="b">sd., col. ;</subfield> <subfield code="c">1/2 in.</subfield> <subfield code="3">viewing copy.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Episode no. 4021.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Sources used: videocassette container; Copyright catalog online; Copyright description.</subfield> </datafield> <datafield tag="655" ind1=" " ind2="0"> <subfield code="a">Situation comedies (Television programs)</subfield> </datafield> <datafield tag="655" ind1=" " ind2="0"> <subfield code="a">Fiction television programs.</subfield> </datafield> <datafield tag="710" ind1="2" ind2=" "> <subfield code="a">Copyright Collection (Library of Congress)</subfield> <subfield code="5">DLC</subfield> </datafield> </record></zs:recordData><zs:recordPosition>2</zs:recordPosition></zs:record><zs:record><zs:recordSchema>info:srw/schema/1/marcxml-v1.1</zs:recordSchema><zs:recordPacking>xml</zs:recordPacking><zs:recordData><record xmlns="http://www.loc.gov/MARC21/slim"> <leader>01718cjm a22003971a 4500</leader> <controlfield tag="001">13463061</controlfield> <controlfield tag="005">20051217130827.0</controlfield> <controlfield tag="007">sd fsngnnmmned</controlfield> <controlfield tag="008">040120r19961983caurcn eng d</controlfield> <datafield tag="024" ind1="1" ind2=" "> <subfield code="a">076744000422</subfield> </datafield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">(DLC) 2004567544</subfield> </datafield> <datafield tag="040" ind1=" " ind2=" "> <subfield code="a">KFW</subfield> <subfield code="c">KFW</subfield> <subfield code="d">IEP</subfield> <subfield code="d">OCLCQ</subfield> <subfield code="d">DLC</subfield> </datafield> <datafield tag="020" ind1=" " ind2=" "> <subfield code="c">$17.98</subfield> </datafield> <datafield tag="024" ind1="1" ind2="0"> <subfield code="a">076744000422</subfield> </datafield> <datafield tag="028" ind1="0" ind2="2"> <subfield code="a">HIPD 40004</subfield> <subfield code="b">Hip-O Records</subfield> </datafield> <datafield tag="028" ind1="0" ind2="2"> <subfield code="a">40004-2</subfield> <subfield code="b">Hip-O Records</subfield> </datafield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="a">(OCoLC)ocm35640234 </subfield> </datafield> <datafield tag="028" ind1="0" ind2="2"> <subfield code="a">HIPD-40004</subfield> <subfield code="b">Hip-O Records</subfield> </datafield> <datafield tag="010" ind1=" " ind2=" "> <subfield code="a"> 2004567544</subfield> </datafield> <datafield tag="042" ind1=" " ind2=" "> <subfield code="a">lcderive</subfield> </datafield> <datafield tag="050" ind1="0" ind2="0"> <subfield code="a">SDA 85496</subfield> </datafield> <datafield tag="245" ind1="0" ind2="4"> <subfield code="a">The '80s hit(s) back!</subfield> <subfield code="h">[sound recording].</subfield> </datafield> <datafield tag="246" ind1="3" ind2=" "> <subfield code="a">Eighty's hit(s) back!</subfield> </datafield> <datafield tag="260" ind1=" " ind2=" "> <subfield code="a">Universal City, Calif. :</subfield> <subfield code="b">Hip-O Records,</subfield> <subfield code="c">p1996.</subfield> </datafield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">1 sound disc :</subfield> <subfield code="b">digital ;</subfield> <subfield code="c">4 3/4 in.</subfield> </datafield> <datafield tag="511" ind1="0" ind2=" "> <subfield code="a">Various performers.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Selections previously released 1983-1988.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Compact disc.</subfield> </datafield> <datafield tag="505" ind1="0" ind2=" "> <subfield code="a">She drives me crazy (Fine Young Cannibals) -- Walk the dinosaur (Was (Not Was)) -- You keep me hangin' on (Kim Wilde) -- The safety dance (Men Without Hats) -- Walking on sunshine (Katrina & The Waves) -- One thing leads to another (The Fixx) -- Heaven is a place on earth (Belinda Carlisle) -- Everybody have fun tonight (Wang Chung) -- Cruel summer (Bananarama) -- Weird science (Oingo Boingo) -- Axel F (Harold Faltermeyer) -- The future's so bright, I gotta wear shades (Timbuk 3).</subfield> </datafield> <datafield tag="650" ind1=" " ind2="0"> <subfield code="a">Rock music</subfield> <subfield code="y">1981-1990.</subfield> </datafield> <datafield tag="655" ind1=" " ind2="7"> <subfield code="a">Compact discs.</subfield> <subfield code="2">lcsh</subfield> </datafield> <datafield tag="906" ind1=" " ind2=" "> <subfield code="a">7</subfield> <subfield code="b">cbc</subfield> <subfield code="c">copycat</subfield> <subfield code="d">3</subfield> <subfield code="e">ncip</subfield> <subfield code="f">20</subfield> <subfield code="g">y-genmusic</subfield> </datafield> <datafield tag="925" ind1="0" ind2=" "> <subfield code="a">acquire</subfield> <subfield code="b">2 copies</subfield> <subfield code="x">policy default</subfield> </datafield> <datafield tag="952" ind1=" " ind2=" "> <subfield code="a">muzerec</subfield> </datafield> <datafield tag="955" ind1=" " ind2=" "> <subfield code="a">vn76 2004-01-20 to MBRS/RS</subfield> <subfield code="e">vn76 2004-01-20 copy 2 to MBRS/RS</subfield> </datafield> <datafield tag="985" ind1=" " ind2=" "> <subfield code="c">OCLC</subfield> <subfield code="e">srreplace 2005-08</subfield> </datafield> </record></zs:recordData><zs:recordPosition>3</zs:recordPosition></zs:record><zs:record><zs:recordSchema>info:srw/schema/1/marcxml-v1.1</zs:recordSchema><zs:recordPacking>xml</zs:recordPacking><zs:recordData><record xmlns="http://www.loc.gov/MARC21/slim"> <leader>01461ngm a22003375a 4500</leader> <controlfield tag="001">11624471</controlfield> <controlfield tag="005">00000000000000.0</controlfield> <controlfield tag="008">930921s1967 xxu vaeng </controlfield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="9">(DLC) 93513624</subfield> </datafield> <datafield tag="906" ind1=" " ind2=" "> <subfield code="a">0</subfield> <subfield code="b">ibc</subfield> <subfield code="c">orignew</subfield> <subfield code="d">u</subfield> <subfield code="e">ncip</subfield> <subfield code="f">19</subfield> <subfield code="g">y-movingim</subfield> </datafield> <datafield tag="010" ind1=" " ind2=" "> <subfield code="a"> 93513624 </subfield> </datafield> <controlfield tag="007">v| ||||||</controlfield> <datafield tag="017" ind1=" " ind2=" "> <subfield code="a">PA608-254</subfield> <subfield code="b">U.S. Copyright Office</subfield> </datafield> <datafield tag="040" ind1=" " ind2=" "> <subfield code="a">DLC</subfield> <subfield code="c">DLC</subfield> <subfield code="e">amim</subfield> </datafield> <datafield tag="050" ind1="0" ind2="0"> <subfield code="a">VBK 2042 (viewing copy)</subfield> </datafield> <datafield tag="245" ind1="0" ind2="0"> <subfield code="a">Abbott & Costello cartoons.</subfield> <subfield code="p">Dinosaur Dilemna /</subfield> <subfield code="c">a Hanna-Barbera Production in association with RKO Pictures Company-Jomar Productions ; directed and produced by Joseph Barbera and William Hanna.</subfield> </datafield> <datafield tag="260" ind1=" " ind2=" "> <subfield code="a">United States :</subfield> <subfield code="b">[s.n.],</subfield> <subfield code="c">1967.</subfield> </datafield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">1 videocassette of 1 :</subfield> <subfield code="b">sd., col. ;</subfield> <subfield code="c">3/4 in. viewing copy.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Copyright: PUB 5May67; PA608-254.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Copyright notice on film: RKO General Inc., Jomar Prod. Inc., Hanna-Barbera Productions, Inc. ; 1967.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">On cassette with episodes: Frigid fugitive ; Invader raider ; Paddleboat pirate.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Number 12</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Animation.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Source used: copyright data sheet.</subfield> </datafield> <datafield tag="541" ind1=" " ind2=" "> <subfield code="d">Received: 4/27/1993;</subfield> <subfield code="3">viewing copy;</subfield> <subfield code="c">copyright deposit--RNR;</subfield> <subfield code="a">Copyright Collection.</subfield> </datafield> <datafield tag="710" ind1="2" ind2=" "> <subfield code="a">Copyright Collection (Library of Congress)</subfield> <subfield code="5">DLC</subfield> </datafield> <datafield tag="740" ind1="0" ind2=" "> <subfield code="a">Dinosaur dilemna.</subfield> </datafield> <datafield tag="740" ind1="0" ind2=" "> <subfield code="a">Abbott and Costello cartoons.</subfield> <subfield code="p">Dinosaur dilemna.</subfield> </datafield> <datafield tag="953" ind1=" " ind2=" "> <subfield code="a">TE01</subfield> </datafield> <datafield tag="969" ind1=" " ind2=" "> <subfield code="a">qxp</subfield> </datafield> <datafield tag="991" ind1=" " ind2=" "> <subfield code="b">c-MP&TV</subfield> <subfield code="h">VBK 2042 (viewing copy)</subfield> <subfield code="w">MUMS VM File</subfield> </datafield> </record></zs:recordData><zs:recordPosition>4</zs:recordPosition></zs:record><zs:record><zs:recordSchema>info:srw/schema/1/marcxml-v1.1</zs:recordSchema><zs:recordPacking>xml</zs:recordPacking><zs:recordData><record xmlns="http://www.loc.gov/MARC21/slim"> <leader>01461ngm a22003375a 4500</leader> <controlfield tag="001">11624468</controlfield> <controlfield tag="005">00000000000000.0</controlfield> <controlfield tag="008">930921s1967 xxu vaeng </controlfield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="9">(DLC) 93513621</subfield> </datafield> <datafield tag="906" ind1=" " ind2=" "> <subfield code="a">0</subfield> <subfield code="b">ibc</subfield> <subfield code="c">orignew</subfield> <subfield code="d">u</subfield> <subfield code="e">ncip</subfield> <subfield code="f">19</subfield> <subfield code="g">y-movingim</subfield> </datafield> <datafield tag="010" ind1=" " ind2=" "> <subfield code="a"> 93513621 </subfield> </datafield> <controlfield tag="007">v| ||||||</controlfield> <datafield tag="017" ind1=" " ind2=" "> <subfield code="a">PA608-252</subfield> <subfield code="b">U.S. Copyright Office</subfield> </datafield> <datafield tag="040" ind1=" " ind2=" "> <subfield code="a">DLC</subfield> <subfield code="c">DLC</subfield> <subfield code="e">amim</subfield> </datafield> <datafield tag="050" ind1="0" ind2="0"> <subfield code="a">VBK 2042 (viewing copy)</subfield> </datafield> <datafield tag="245" ind1="0" ind2="0"> <subfield code="a">Abbott & Costello cartoons.</subfield> <subfield code="p">Frigid fugitive /</subfield> <subfield code="c">a Hanna-Barbera Production in association with RKO Pictures Company-Jomar Productions ; directed and produced by Joseph Barbera and William Hanna.</subfield> </datafield> <datafield tag="260" ind1=" " ind2=" "> <subfield code="a">United States :</subfield> <subfield code="b">[s.n.],</subfield> <subfield code="c">1967.</subfield> </datafield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">1 videocassette of 1 :</subfield> <subfield code="b">sd., col. ;</subfield> <subfield code="c">3/4 in. viewing copy.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Copyright: PUB 12May67; PA608-252.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Copyright notice on film: RKO General Inc., Jomar Prod. Inc., Hanna-Barbera Productions, Inc. ; 1967.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">On cassette with episodes: Invader raider ; Dinosaur dilemna ; Paddleboat pirate.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Number 12.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Animation.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Source used: copyright data sheet.</subfield> </datafield> <datafield tag="541" ind1=" " ind2=" "> <subfield code="d">Received: 4/27/1993;</subfield> <subfield code="3">viewing copy;</subfield> <subfield code="c">copyright deposit--RNR;</subfield> <subfield code="a">Copyright Collection.</subfield> </datafield> <datafield tag="710" ind1="2" ind2=" "> <subfield code="a">Copyright Collection (Library of Congress)</subfield> <subfield code="5">DLC</subfield> </datafield> <datafield tag="740" ind1="0" ind2=" "> <subfield code="a">Frigid fugitive.</subfield> </datafield> <datafield tag="740" ind1="0" ind2=" "> <subfield code="a">Abbott and Costello cartoons.</subfield> <subfield code="p">Frigid fugitive.</subfield> </datafield> <datafield tag="953" ind1=" " ind2=" "> <subfield code="a">TE01</subfield> </datafield> <datafield tag="969" ind1=" " ind2=" "> <subfield code="a">qxp</subfield> </datafield> <datafield tag="991" ind1=" " ind2=" "> <subfield code="b">c-MP&TV</subfield> <subfield code="h">VBK 2042 (viewing copy)</subfield> <subfield code="w">MUMS VM File</subfield> </datafield> </record></zs:recordData><zs:recordPosition>5</zs:recordPosition></zs:record><zs:record><zs:recordSchema>info:srw/schema/1/marcxml-v1.1</zs:recordSchema><zs:recordPacking>xml</zs:recordPacking><zs:recordData><record xmlns="http://www.loc.gov/MARC21/slim"> <leader>01458ngm a22003375a 4500</leader> <controlfield tag="001">11624469</controlfield> <controlfield tag="005">00000000000000.0</controlfield> <controlfield tag="008">930921s1967 xxu vaeng </controlfield> <datafield tag="035" ind1=" " ind2=" "> <subfield code="9">(DLC) 93513622</subfield> </datafield> <datafield tag="906" ind1=" " ind2=" "> <subfield code="a">0</subfield> <subfield code="b">ibc</subfield> <subfield code="c">orignew</subfield> <subfield code="d">u</subfield> <subfield code="e">ncip</subfield> <subfield code="f">19</subfield> <subfield code="g">y-movingim</subfield> </datafield> <datafield tag="010" ind1=" " ind2=" "> <subfield code="a"> 93513622 </subfield> </datafield> <controlfield tag="007">v| ||||||</controlfield> <datafield tag="017" ind1=" " ind2=" "> <subfield code="a">PA608-253</subfield> <subfield code="b">U.S. Copyright Office</subfield> </datafield> <datafield tag="040" ind1=" " ind2=" "> <subfield code="a">DLC</subfield> <subfield code="c">DLC</subfield> <subfield code="e">amim</subfield> </datafield> <datafield tag="050" ind1="0" ind2="0"> <subfield code="a">VBK 2042 (viewing copy)</subfield> </datafield> <datafield tag="245" ind1="0" ind2="0"> <subfield code="a">Abbott & Costello cartoons.</subfield> <subfield code="p">Invader raider /</subfield> <subfield code="c">a Hanna-Barbera Production in association with RKO Pictures Company-Jomar Productions ; directed and produced by Joseph Barbera and William Hanna.</subfield> </datafield> <datafield tag="260" ind1=" " ind2=" "> <subfield code="a">United States :</subfield> <subfield code="b">[s.n.],</subfield> <subfield code="c">1967.</subfield> </datafield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">1 videocassette of 1 :</subfield> <subfield code="b">sd., col. ;</subfield> <subfield code="c">3/4 in. viewing copy.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Copyright: PUB 1Jun67; PA608-253.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Copyright notice on film: RKO General Inc., Jomar Prod. Inc., Hanna-Barbera Productions, Inc. ; 1967.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">On cassette with episodes: Frigid fugitive ; Dinosaur dilemna ; Paddleboat pirate.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Number 12.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Animation.</subfield> </datafield> <datafield tag="500" ind1=" " ind2=" "> <subfield code="a">Source used: copyright data sheet.</subfield> </datafield> <datafield tag="541" ind1=" " ind2=" "> <subfield code="d">Received: 4/27/1993;</subfield> <subfield code="3">viewing copy;</subfield> <subfield code="c">copyright deposit--RNR;</subfield> <subfield code="a">Copyright Collection.</subfield> </datafield> <datafield tag="710" ind1="2" ind2=" "> <subfield code="a">Copyright Collection (Library of Congress)</subfield> <subfield code="5">DLC</subfield> </datafield> <datafield tag="740" ind1="0" ind2=" "> <subfield code="a">Invader raider.</subfield> </datafield> <datafield tag="740" ind1="0" ind2=" "> <subfield code="a">Abbott and Costello cartoons.</subfield> <subfield code="p">Invader raider.</subfield> </datafield> <datafield tag="953" ind1=" " ind2=" "> <subfield code="a">TE01</subfield> </datafield> <datafield tag="969" ind1=" " ind2=" "> <subfield code="a">qxp</subfield> </datafield> <datafield tag="991" ind1=" " ind2=" "> <subfield code="b">c-MP&TV</subfield> <subfield code="h">VBK 2042 (viewing copy)</subfield> <subfield code="w">MUMS VM File</subfield> </datafield> </record></zs:recordData><zs:recordPosition>6</zs:recordPosition></zs:record></zs:records></zs:searchRetrieveResponse> I have a directory full of pictures that I would like to display in a gallery. Originally I was going to write HTML like this...
<li> <img src=/photos/img_001.jpg"> </li>
And then simply copy and paste that for the number of photos I have, and then tweak the code to: img_002.jpg, img_003.jpg, and so on. I guess that is silly considering that I have over 500 photos to display! How could I use PHP to go to my /photos/ directory, scan all of the files in that directory, and then grab the file name so I could automate this process? Sorry, but I haven't written PHP in several years so all of this escapes me! ☹️ Hi guys, im logging activity on my site to text files using; Code: [Select] date_default_timezone_set('GMT'); $LogFileLocation = "xxxxxxxx.log"; $fh = fopen($_SERVER['DOCUMENT_ROOT'].$LogFileLocation,'at'); fwrite($fh,date('d.M.Y H:i:s')."\t".$_SERVER['REMOTE_ADDR']."\t".$_SERVER['REQUEST_URI']."\n"); fclose($fh); This is write something like; [date] [time] [ip address] [folder accessed] I then post it like; Code: [Select] <? $fn = "xxxxxxxxxx.log"; print htmlspecialchars(implode("",file($fn))); ?> That works fine but what i want to be able to do is read/edit the text files, so the main things i need to add is; The ability to clear the log (using password for confirmation) not sure how to go about this because i don't know how to edit the text file <input name="password" type="text"> <input type="submit" value="Clear Log?"> I also need a script to read the log and alert me an ip address that isn't mine is found, maybe something like if (an ip that isn't mine == yes) echo "an unknown ip accessed something" Also lets say i have a script that checks if a name exists, how can i use a text file containing a list of names to be read by a script if (name exists in text file) echo "name exists" else echo "name doesn't exist" All these questions are similar in the fact i need to understand how to open and read text files for specific entries, hope you understand, thanks for any help. Is it possible to read from a file that is located on the user's local machine and not on the server? I have a CSV file that is about 70MB that I have to parse through and insert the data into a database. I have no problem doing this if I hard code the path to the file. Is there a way to get the path of the file that the user wants to be parsed into the database? I don't think uploading the file would be a good idea because, like I said, it is 70MB and is nearly 2 million lines. Simply parsing the file takes long enough without throwing in upload time.. I have the two files below and want to separate php and html. How do I output forum.html with forum_post.html in it? I want to post as many forum_post.html as mysql_num_rows() says. Code: [Select] forum.html ====== <div> <form method="post"> <textarea name="text"></textarea> <input type="submit" /> </form> </div> <div> [b]???[/b] </div> Code: [Select] forum_post.html ====== <div> <h1>Title</h1> <p>Text</p> </div> Hi, how do I output the total files in a given directory? Here is code I cannot get to work: Code: [Select] <?php $file=fopen('C:\\dir\\folder\\proj_ath\\', 'a+'); for($i=0;$i<count($file);$i++) { print "tot files so far: $i <br />"; } ?> Any help much appreciated! Hi I have this script that saves data to a file, I was wondering how I can make the script write the title of the files in uppercase letters? I am new to coding mind I think is the relevent code: Code: [Select] foreach(array('daily','weekly','monthly') as $value) { $fp = fopen(DIR.$value.'_'.strtolower(str_replace('/', '', $data[$ccyValue][0])).'.csv', 'w'); if($fp) { $raw_data = array(${$value.'Pivot'}, ${$value.'_s1'}, ${$value.'_s2'}, ${$value.'_s3'}, ${$value.'_r1'}, ${$value.'_r2'}, ${$value.'_r3'}); $write_data = "Pivot, S1, S2, S3, R1, R2, R3\n"; $write_data .= implode(',', $raw_data); fwrite($fp,$write_data); fclose($fp); } else { die('Please make sure result folder is present or writable!'); } } } Thanks Antony I'm trying to use PHP to read data from EDGAR, the SEC's website for company filings. Filings are in XBRL, a standard for XML. I'm having trouble pulling data using PHP. Here is a link to the data: http://www.sec.gov/Archives/edgar/da...g-20101231.xml Using PHP, I'm trying to get the data from, for example, the following tag: <us-gaap:Assets contextRef="eol_PE633170--1010-K0013_STD_0_20091231_0" unitRef="iso4217_USD" decimals="-6">40497000000</us-gaap:Assets> I've been unsuccessful thus far in getting this data - do you have any suggestions on how to do that? Thank you! Hi, guys. I'm trying to wrap my head around trying to read a header in a binary file in php. So, far, I have been able to get the data into a string using file_get_contents. Now, I think I need to use unpack, but it's a bit confusing to me still. For example, my file starts by having a 1 byte version number, 4 bytes to represent a number of walls, then "number of walls" * 40 bytes for the actual walls. But, the problem is, the wall itself is a structure composed of various elements to make up that 40 bytes, from which I'll need to pick out a specific area of interest. I can do this easily in C, but in php. I can't think how to grab the info. Any ideas? Maybe just how to read 1 byte, 4 bytes, then "number of walls" * 40 bytes will get me in the right direction. Hello again. I'm trying to load data from a Facebook Share Data XML file and then displaying them in a WordPress plugin. Here's my code so far: // Fetch Share Count Data function fb_button () { $fbshareUrl = urlencode(get_permalink($post->ID)); $fbshareTitle = urlencode($post->post_title); $fbLinkStats = simplexml_load_file('http://api.facebook.com/restserver.php?method=links.getStats&urls='.$shareUrl); $fb_params = '?u=' . $fbshareUrl . '&t=' . $fbshareTitle . '' ; // Vertical Facebook Button $fb_share = ' <div class="fsbsharer" id="fb"> <a href="http://www.facebook.com/sharer.php' . $fb_params . '" class="facebookShare"> <span class="fb_share_size_Small fb_share_count_wrapper"> <span></span> <span class="fb_share_count_nub_top "></span> <span class="fb_share_count fb_share_count_top"> <div class="fb_share_count_inner"> '. $fbLinkStats->link_stat->total_count .' </div> </div> <span style="cursor:pointer;" class="FBConnectButton FBConnectButton_Small"><span class="FBConnectButton_Text">Share</span></span> </a> </div> '; echo $fb_share; } This code works for everything except the title and the share count. I can fix the title myself but the share count isn't working. When I use this in plain HTML: <?php echo $fbLinkStats->link_stat->total_count.''; ?> it works fine, but when I combine it all into another function to echo, it no longer works properly. Thanks. OK, so I am trying to read exif data from images and have come up against a snag that I cannot see the answer to. I know that what I have at present is pretty basic, but I want to be sure that I know how to access the bits I want before tidying it up into something more sophisticated. The coide I have is this:- Code: [Select] $exif = exif_read_data('brass jaw.jpg', 'EXIF'); $name = $exif['FileName']; $height = $exif['ExifImageWidth']; $width = $exif['ExifImageLength']; $model = $exif['Model']; $exposuretime = $exif['ExposureTime']; $fnumber = $exif['FNumber']; $iso = $exif['ISOSpeedRatings']; $date = $exif['DateTime']; echo "File Name: $name<br />"; echo "Height: $height<br />"; echo "Width: $width<br />"; echo "Camera: $model<br />"; echo "Shutter Speed: $exposuretime<br />"; echo "F number: $fnumber<br />"; echo "ISO: $iso<br />"; echo "Date & Time: $date<br />"; var_dump($exif); This code produces the following:- File Name: brass jaw.jpg Height: 640 Width: 360 Camera: Canon EOS 550D Shutter Speed: 244/1000000 F number: 8000000/1000000 ISO: Array Date & Time: 2011:09:17 13:52:30 Which serves quite well apart from the ISO, which comes back as "Array". Now when I do a var_dump I see that ISOSpeedRatings returns as this:- 'ISOSpeedRatings' => array 0 => int 800 1 => int 800 What I can't work out is how to access the information from this - I know that the solution will probably be very simple, and that I will end up kicking myself, but I could use a little help. hello everyone, please anyone can help me how to read data of excel file in php Hello All, Please excuse my lack of knowledge in advance, I'm a beginner but pick things up relatively quickly, and tend to do things by trial and error. I would appreciate any help that anyone could offer with the following: I would like to retrieve two pieces of data from a "text file" and use them to calculate a result from a function I have in javascript. An example of the javascript code is: <script type="text/javascript"> function calculate() { var drybulb = document.calc_form.drybulb.value; var relhum = document.calc_form.relhum.value; var answer = ''; if (drybulb !== '' && relhum !== '') { answer = (0.567*drybulb*1) + (0.393 * (relhum*1/100 * 6.105 * Math.exp(17.27 * drybulb / (237.7 + drybulb*1)))) + 3.94; } document.calc_form.answer.value = answer; return false; } </script> Currently this is evaluated with entry from a simple html form, but I would like to have this performed "automatically". The "text file" that I would like to access is here, not on my server: http://www.bom.gov.au/fwo/IDV60901/IDV60901.94870.axf I would like to extract the "air_temp" and "rel_hum" values under the [data] section for use in my function. I just need the "most recent" values (i.e. first), not all those contained in the file. This is a single record from that section (sorry for the mess this no doubt makes): [data] sort_order,wmo,name[80],history_product[80],local_date_time[80],local_date_time_full[80],aifstime_utc[80],air_temp,apparent_t,cloud[80],cloud_base_m,cloud_oktas,cloud_type[80],cloud_type_id,delta_t,dewpt,gust_kmh,gust_kt,lat,lon,press,press_msl,press_qnh,press_tend[80],rain_trace[80],rel_hum,sea_state[80],swell_dir_worded[80],swell_height,swell_period,vis_km[80],weather[80],wind_dir[80],wind_spd_kmh,wind_spd_kt 0,94870,"Moorabbin Airport","IDV60901","27/10:00pm","20120227220000","20120227110000",18.8,19.3,"Partly cloudy",510,3,"-",-9999,0.8,17.5,13,7,-38.0,145.1,1013.5,-9999.0,1013.5,"-","11.4",92,"-","-",-9999.0,-9999,"10","-","S",11,6 Would it be possible to obtain these values using PHP?, and if so any advice on how this could be done (noting my minimal knowledge) would be greatly appreciated. Cheers. Hi, I have an image (a weather map) which is created using php which pulls data from a mysql database. I would like to be able to output the result image as a gif or jpg file. Can anyone suggest how this could be done? Many thanks, Simon Hey guys, newbie here love the site, lots of great info, hopefully one of u guys can help me out. i have adapted code from http://www.singhvishwajeet.com/2009/06/25/using-php-to-get-stock-quotes-from-yahoo-finance/ (which is free to use) i have been working on a way to enter a company code, e.g. BARC -barclays bank, on one page then on another im trying to serahc the yahoo csv for a number of specific numbers that are "live" and then output them on my site, which in turn i shall work with but i cant seem to out put the data, its the $stat bit im struggling with i will attach the files, hopefully someone can help me Hello, I seem to have some problem with my script that has a goal of outputting data about the file size when a filename is queried.
The sql table name is file
The table columns are as followed: id | name | mime | size
The file name is stored in name. The script that i have that gets the file name is:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Adobe GoLive" /> <title>File Select</title> <!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.--><script>var __adobewebfontsappname__="dreamweaver"</script><script src="http://use.edgefonts.net/aguafina-script:n4:default.js" type="text/javascript"></script> </head> <body> <div id="title"> <h3 align="center">File Upload</h3> </div> <form action="result.php" method="post" name="fileID" target="_self" class="inp" AUTOCOMPLETE="ON"> <h1> <!--Input file name--> <label for="fileID">File Name: </label> <input type="text" name='file1' id='sampleID' list="samp"> </input><br> <datalist id="samp"> <?php $connect = mysql_connect('localhost', 'root', ''); mysql_select_db("test_db"); $query = mysql_query("SELECT * FROM `file` ORDER BY `file`.`name` ASC LIMIT 0 , 30"); WHILE ($rows = mysql_fetch_array($query)): $File_name = $rows['name']; echo "<option value=$File_name>$File_name/option> <br>"; endwhile; ?> </datalist> <input type="submit" class="button" > </form> </body> </html> |