PHP - Xml Dom Reading Is Working But Need Output Rearranged
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> Similar Tutorialstrying 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); ?> I'm testing out small bits of code for myself, and I'm trying to understand why this isn't coming out how I would imagine it to... I have my function which stores colors in an array from a text file, then I return back a random color from my array like so... function getColor() { $ball_color = explode("\n", file_get_contents('colors.txt')); // Takes file contents and stores them into an array. return $ball_color[array_rand($ball_color)]; } And now in the main program, I simply have this: $color = getColor(); switch($color) { Case "blue": // echo stuff break; Case "red": // echo stuff break; etc... } For some reason though, my switch statement always reads the default case, making me assume that the words "blue" "red" "green" etc... aren't matching up to what I have set the cases at. When I output what color is actually being read, it displays exactly as it should, so I don't understand why the case "red" isn't opening up when that color is chosen, or same with any of the other colors. Is there some small conflict I'm unaware of in this tiny practice code? Any help is appreciated, thanks. <?PHP require("../fpdf/fpdf.php"); include("db.classes.php"); $g = new DB(); $g->connection(); class PDF extends FPDF { .....codes..... } $pdf = new PDF(); .....codes..... $pdf->SetFont('Arial','',14); $pdf->AddPage('L', 'Legal'); $pdf->SetXY(20,20); $pdf->image('../images/DCWD Watermark.png'); $pdf->SetY(35); // call the table creation method $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,$plateNo); $pdf->SetY(45); $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,$model); $pdf->SetXY(310, 45); $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,date("m/d/Y")); $pdf->SetY(55); $pdf->BuildTable($header,$data); $pdf->Output(); ?>Why is FPDF's Output not working? or is something wrong with my browser? I already tried putting paramaters on it but still no go I tried Output('foo.pdf','I') not working but if i itegrate my chrome withIDM it just downloads but when i disable integrationnothing happens. Code: [Select] //display an external link or form button if ($product_link = $meta['mp_product_link']) { $button = '<a class="mp_link_buynow" href="' . esc_url($product_link) . '">' . __('Buy Now »', 'mp') . '</a>'; } else { if ($all_out) { $button .= '<span class="mp_no_stock">' . __('Out of Stock', 'mp') . '</span>'; } else { $button = '<div class="mp_product_variations" name="variation">'; //create select list if more than one variation if (is_array($meta["mp_price"]) && count($meta["mp_price"]) > 1 && empty($meta["mp_file"])) { // for each as foreach ($meta["mp_price"] as $key => &$value) { $disabled = (in_array($key, $no_inventory)) ? ' disabled="disabled"' : ''; $variation_select = '<form name="' . $key . '" class="mp_buy_form" method="post" action="' . mp_cart_link(false, true) . '">\n'; $variation_select .= '<input type="hidden" name="product_id" value="' . $post_id . '" />'; $variation_select .= '<input type="hidden" name="variation" value="' . $key . '">'; $variation_select .= '<span>' . esc_html($meta["mp_var_name"][$key]) . ' - '; if ($meta["mp_is_sale"] && $meta["mp_sale_price"][$key]) { $variation_select .= $mp->format_currency('', $meta["mp_sale_price"][$key]); } else { $variation_select .= $mp->format_currency('', $value); }$variation_select .= "</span>\n"; if ($context == 'list') { if ($variation_select) { $variation_select .= '<a class="mp_link_buynow" href="' . get_permalink($post_id) . '">' . __('Choose Option »', 'mp') . '</a>'; } else if ($settings['list_button_type'] == 'addcart') { $variation_select .= '<input type="hidden" name="action" value="mp-update-cart" />'; $variation_select .= '<input class="mp_button_addcart" type="submit" name="addcart" value="' . __('Add To Cart »', 'mp') . '" />'; } else if ($settings['list_button_type'] == 'buynow') { $variation_select .= '<input class="mp_button_buynow" type="submit" name="buynow" value="' . __('Buy Now »', 'mp') . '" />'; } } else { $button .= $variation_select; //add quantity field if not downloadable if ($settings['show_quantity'] && empty($meta["mp_file"])) { $button .= '<span class="mp_quantity"><label>' . __('Quantity:', 'mp') . ' <input class="mp_quantity_field" type="text" size="1" name="quantity" value="1" /></label></span> '; } if ($settings['product_button_type'] == 'addcart') { $button .= '<input type="hidden" name="action" value="mp-update-cart" />'; $button .= '<input class="mp_button_addcart" type="submit" name="addcart" value="' . __('Add To Cart »', 'mp') . '" />'; } else if ($settings['product_button_type'] == 'buynow') { $button .= '<input class="mp_button_buynow" type="submit" name="buynow" value="' . __('Buy Now »', 'mp') . '" />'; } } $variation_select .= "</form>\n"; } //end for each $variation_select .= '</div>'; } else { $button .= '<input type="hidden" name="variation" value="0" />'; } } } Everything inbetween "for each" is being looped, except for the <form>. How can I get it to include <form> and </form> in the loop? Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. [xml]<category id="SOCMENEURASTVICLEA" order="26800">Aus. Victoria League</category>[/xml] I have the above xml, I can read the category id, order but I dont no how to read the value "Aus. Victoria League" foreach($description->children() as $category) { foreach($category->attributes() as $a => $b) { echo "<br/> -------- "; echo $a,'="',$b,"\"\n"; } echo "category name" . $category->asXML(); } the asXML() i have no idea what that is but am guessing I need thats where the php function which returns the value needs to go Thank you Hello, I'm trying to read some XML by name this is the XML: Code: [Select] <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <imgdir name="01040000.img"> <imgdir name="info"> <canvas name="icon" width="29" height="30" basedata="iVBORw0KGgoAAAANSUhEUgAAAB0AAAAeCAYAAADQBxWhAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMuSURBVEhLlZcBlatADEWxUAu1gAUs1AIWsIAFLGChFmphLXwL83ND3jQwlO5yTg6FmcnNSzLDbtf97io27Zv9ztOHWY3zZezKOHSl7/ud8Y6x1/IxoK+BOGwd+zIN99LfN4dnQGAVuG5zmD8Nt7I87u6D55SdU3jh2hZuwPK6lfJvKq9wmkH/nhtId+bPBvtZRgeOva219WQgZaEB++DjfqtQHArs9wjCnVkgCoZ1QIGhEuBgfvyyoJlPgKG6gn1AwKo0FjjcfisIqXOwAW83MysLqZ0MyD0r9Wy9a/6GKloBH7YYZx4plwUlqGBE70CZgVGaU4xifJ+pdZWkRw0AlGhx+JwDHmnNsN7GZahVioFLsac66ptTvKXFjNr0/bB1LvWxptqpCVUERaAC4hgo5kAbVxdL7THFNSUZiuPF1KvW+TdjlAKHgAVFicCoJtVqLvf93kZbWngxPMaqVGpwzsLcaAIKChgYUHxUxWquyCTzleK6TaZp9kUMKEJg7jwiBahtIZVZrXwo3Vp3VEobOyxDmQSw7rc4KDwjEUhOsdTiY56X6ktwZSKfED4Rk1Lvutir+XTxIy8aqnZudLHv14BmMM15PBxc6bI+a4SLPb/Mfsxstt95xhjDprCH3TGeee/1XNed2jOoR5ehcpDBGX4FPkJzyZrUCkp6z5RK7TelW9bWRm1z9qqeiupuCzF92vR505fm7MDQO5zj75jiBiqYmsj3KJ+naCR9VThVCEDj3POW4FlQ+fQT7qqRmMgiTpLnNOzA+qThmDHN4aSabe9iOnGkUh181rnevdlwxB4kZXIodfrQa85RtdQefF7+2eIKstJcP4BSmefxTor9UIk0f/0DKSb4YlSycPCvzvuPMaLXYc88zdV81fjP0FwrAcdxLJhvB4NltfzOSinHX6A7lR61qcxAg9reP1d7Udvv9VTU27e1gfaf1CrdufGimVhj294Dbq5ayw9AOx072a621FSW925AR7vb8dwBb8CeXprnuIXseTazE3BnzX7NezZ8EOQl1OsVRmRMxrLC4++r/2/wMYTCj+kl34CZICMlR5Oj4/u8ThD8NSn9D9wL1z9uxdBdAAAAAElFTkSuQmCC"> <vector name="origin" x="-2" y="30"/> </canvas> <canvas name="iconRaw" width="29" height="29" basedata="iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL4SURBVEhLlZYBtYMwDEVnAQuzgAUsYAELWMACFrAwC7MwC99Cf27o6wJ0sO2cHAZNc/PStHC7ffdL5nZl30X64HUIPg+3NHS31LbtxnjG2HP+mNBlIg5bhjaN3T219zVgDQisAJfVB/+xa9Lc3z0G96E6VXjit05cgenZpPQ3pmcOGkF/jxWkK/6TwV7z4MChtbk2nwqEKhzAPtjfmwIloMB+zUl4MEtEyTAPKDBUAuwsjv8safxJMKsuYB8QsCjNExxu/5WE1DnYgE1jZstCaUcDco1KvVrvNX9Dla2AvU0mmGfKz5ISVDCyd6DMwCiNJUYxsWtqXSXlUQMAJVsCPqYMz2WNsNbGZahViYFLsZc6r28s8VoWM9ambbu1c1kfa6qNmqyKpEhUQAIDxRxo4+piqd2XuJQkQgk8m3qtdfzPGEtBQMCCokRgVFNqNZfHfm+jtSw86PqhKJUagjMxNpqAggIGBpQYRbGaK1cSf5W4bJNxnHwSA8oQmAfPmQLUtpDKqFYxVG7N2yuljR0WoTgBLPstHxRekZxILLHUEmOa5hJLcFUinhDuiEmpd13eq/F08SMvN1Tp3NzFvl8zNIJpzv3h4Ern5VEynO3+afYyM2+/co8xho3Zerti3PPc13NZNmprUM8uQhUggiP8DLyHxiU7lFZQyltTKrVXSteqLQe1h7NX66ms7jYR06tNrze9aWoHhp4RnHj7Eh+ggqmJfI/yesqNpLcKpwoJaJxr3BLcC6qYfsKdNRKOTOIkeYzdBqxXGoEZkw8n1WR7F9OJI5Xq4FrnevdGIxB7kJIpoNTpRS+fvWqp3cU8/WxxBVFpXD+AUhn9eCbFfqjkMl9+IGUHn4xKJnb+1nl/jJG9Dnv85Ct/rfHP0LhWAg7DkDDfDgaLavkflbIcv0A3Kj1rUxmBqkZN7cnaXq+nsl7frXVoTa3KHRvvU9duTiatzQlQ/pu1ZZ4s7t2voGRL8+y30If6HPZr3LPfAIuCX5wryV1+1QP6B07yxunYFCcQAAAAAElFTkSuQmCC"> <vector name="origin" x="-2" y="30"/> </canvas> <string name="islot" value="Ma"/> <string name="vslot" value="Ma"/> <int name="reqJob" value="1"/> <int name="reqLevel" value="40"/> <int name="reqSTR" value="130"/> <int name="reqDEX" value="0"/> <int name="reqINT" value="0"/> <int name="reqLUK" value="0"/> <int name="incDEX" value="3"/> <int name="incMMP" value="10"/> <int name="incPDD" value="45"/> <int name="tuc" value="7"/> <int name="price" value="6700"/> <int name="cash" value="0"/> </imgdir> Say I want to get reqJob and print it onto the page. Also I would need to get the BaseData of the iconRaw canvas. The following script just validates some form inputs, and then puts any errors inside an array. I get this error: Fatal error: Cannot use [] for reading in C:\xampp\htdocs\Game\includes\validation.php on line 104 I've looked around, and this still does not make any sense to me. public function ValidateEmail($email, $reemail){ /* Sanatize. User filter_var to validate. Make sure both emails match. Check if email already exists or not. */ trim($email); strip_tags($email); mysql_real_escape_string($email); trim($reemail); strip_tags($reemail); mysql_real_escape_string($reemail); if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $this->valid = false; //Line 104 $this->error[] - "The E-Mail that you provided is not valid."; } else { $this->valid = true; } if($email !== $reemail){ $this->valid = false; $this->error[] = "The E-Mail's that you provided do not match."; } else { $this->valid = true; } if(filter_var($email, FILTER_VALIDATE_EMAIL) && $email == $reemail){ $checkmail = mysql_query("SELECT users.email, temp_users.email FROM users, temp_users WHERE email = '$email'"); if(mysql_mum_rows($checkmail) == 1){ // email is found, throw out error $this->valid = false; $this->error[] = "That E-Mail is already in use."; } else { $this->valid = true; } } return $this->error; } Line 104 is commented out. Thanks! how can I read a url coming from another site by header('Location:') command PHP 5.3.8 XAMPP on Windows XP I have an XML file that manages the input to an mp3 player on this page http://www.jimslounge.com/segovia/ The structure looks like this Code: [Select] <content> <auto_play>yes</auto_play> <loop>yes</loop> <volume>60</volume> <artist> <song_title><![CDATA[Bach - Suite No. 3 - Allemande]]></song_title> <artist_name><![CDATA[Andre Segovia]]></artist_name> <image_path>load/images/segovia.jpg</image_path> <mp3_path>load/songs/Bach - Suite No. 3 (for solo cello, arr. Duarte)- Allemande.mp3</mp3_path> <url target="_blank" open="yes">http://en.wikipedia.org/wiki/Andr%C3%A9s_Segovia</url> </artist> <artist> ... with <artist> being the repeating element I want to be able to read and eventually write to If I run this Code: [Select] $xml = simplexml_load_file("load.xml"); var_dump($xml); I get this object(SimpleXMLElement)#1 (4) { ["auto_play"]=> string(3) "yes" ["loop"]=> string(3) "yes" ["volume"]=> string(2) "60" ["artist"]=> array(22) { => object(SimpleXMLElement)#2 (5) { ["song_title"]=> object(SimpleXMLElement)#24 (0) { } ["artist_name"]=> object(SimpleXMLElement)#25 (0) { } ["image_path"]=> string(23) "load/images/segovia.jpg" ["mp3_path"]=> string(74) "load/songs/Bach - Suite No. 3 (for solo cello, arr. Duarte)- Allemande.mp3" ... [/color] which is overwhelming This cleans it up but doesn't give me the artist name and song name I'm looking for. Code: [Select] $xml = simplexml_load_file("load.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } The Output: content auto_play: yes loop: yes volume: 60 artist: artist: artist: My experience with simplexml only goes back a couple of hours so I'm pretty inept at this point. Any help will be greatly appreciated. I just can't wrap my head around it, but I am trying to integrate weather into my website using NOAA. 1. Here is the NOAA page: http://forecast.weather.gov/MapClick.php?CityName=Mio&state=MI&site=APX&lat=44.663&lon=-84.1446 2. Here is the XML to that page: http://forecast.weather.gov/MapClick.php?lat=44.66300&lon=-84.14460&FcstType=dwml Now what I want to do is to have PHP on my website that reads the XML from the NOAA site and create the "Forecast At A Glance". Possible or too challenging? I've never been very good with arrays, and am totally new to them in PHP... If I have this array... Code: [Select] $concertDates = array('201105071'=>'May 7, 2011 (9:00am - 12:00pm)', '201105072'=>'May 7, 2011 (1:00pm - 4:00pm)', '201105141'=>'May 14, 2011 (9:00am - 12:00pm)'); ...and I know the key, e.g. Code: [Select] $concertDate = '201105072' Then how do I get the corresponding value, i.e. Code: [Select] May 7, 2011 (1:00pm - 4:00pm)' ...from the array?? Debbie Hi all, how do I read emails sent to an email account on my site such as admin@mysite.com? Hi there I am working on PHP form which has an array named: $productOptions. When I do: print_r($productOptions); it returns: Array ( [124] => Array ( [optionId] => 124 [optionName] => acer aspire [optionListId] => 28 [dateCreated] => 2010-11-04 12:48:53 [enabled] => 1 [optionQtyId] => 84 [productId] => 40 [quantity] =>7 ) [114] => Array ( [optionId] => 114 [optionName] => acer fast [optionListId] => 28 [dateCreated] => 2010-11-01 02:04:53 [enabled] => 1 [optionQtyId] => 83 [productId] => 40 [quantity] => 0 ) Now from this Array, I would like to check if the quantity if greater than Zero. so I tried: if (productOptions[quantity] > 0){ echo "blah blah..." } But for getting the quantity, the part: productOptions[quantity] returns nothing. Am I doing this correctly? Please reply. Thank you Hi People. Here is a form that is supposed to read from my database. My primary key is called "index" and I have about 300 records in the database. I wanted to be able to view the records but when I load this page the "php" part is empty. I simply get given a blank form. I know it is connecting to the DB OK because I changed one letter in the password and then got a "can't connect to the database error" just to test it out. Code: [Select] <?php $host = 'localhost'; $usr = "the_db_user"; $password = 'not_shared_on_forum'; $db_name = 'stranded'; function cr($string){ $clean_string = str_replace("rn","<BR>",$string); return $clean_string; } //$id = 11; if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from HelperFormData where index = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> Surname: <? echo $rs["surname"]; ?> <table width="500" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="2"> <tr> <td colspan="5">Record number: <? echo $rs["index"]; ?></td> </tr> <tr> <td width="120" bgcolor = #E6F8EB>Surname</td> <td width="120" bgcolor = #E6F8EB>First Name</td> <td width="120" bgcolor = #E6F8EB>phone1</td> <td width="120" bgcolor = #E6F8EB>phone2</td> <td width="120" bgcolor = #E6F8EB>Location</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo $rs["surname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["firstname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone1"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone2"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["location"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Qualifications</td> <td bgcolor = #dbeff8>Expertise</td> <td bgcolor = #dbeff8>Assistance</td> <td bgcolor = #dbeff8>Languages</td> <td bgcolor = #dbeff8>E-Mail</td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["qualifications"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["expertise"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["assistance"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["languages"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["e_mail"]; ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Consent</td> <td bgcolor = #E6F8EB>Published</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo $rs["consent"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_callsign"]; ?></strong></td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td colspan="5"><p>Comments:<br /> <strong><? echo $rs["comments"]; ?></strong></td> </tr> </table> </body> </html> </html> hi i am a making a site in which m saving a songs information in database then fetching that out for inserting song link m using readdir function that read all song in a folder then save them in database but i have problem when that read file name .mp3 also include with that which i don't want to show on page where i fetch that mean simply i want that i can insert song name separately and file separately... and i want to use readdir also for getting file name becoz that easy way instead of upload through panel ..? any idea or solution about adding separately file name I have been studying PHP for a long time. I can write a simple PHP guestbook now. But you know, it's so so so simply, even the green hand can attack on my site. I want to improve my PHP skill, so i decide to read a big php program such as a shopping cart. Finally i choose the cart Eclime. But when i read the code, i find it's so difficult for me to understand it. Maybe i am in the wrong way to study PHP. Anyone tell me what i should do now ... |