PHP - Newb Q - Reading Records From Mysql But No Output
Similar TutorialsI have created script that puts user information in MySQL database table called "Users" when they register. Now i want to create page to show all the accounts in that table and some custom fields they filled in as well. Like Name, Age, Sex. My table is 1Name 2Age 3Sex 4Email John 22 M john@gmail.com Kate 34 F kate@yahoo.com etc... I trying to show all users at once, so far i pulled info one by one successefully, and also queried that entire table trough array, but its creates huge list on one page i dont like this, i need to separate it to 10 accounts per page. How can i do that? I also like page 1, page2, page3 be linkable from homepage is there way to make them have static page like http://site.com/users.php?pages=2. Please advise. 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> 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); ?> The following query or while loop is only increasing the ArticleID variable every 3rd time the script is run, I've narrowed it down to the following code snippet. Can you spot a problem with this, I'm in my first week of PHP and MySQL and I can't see any problem with it. Any help would be mighty appreciated by this idiot Code snippet: --- $result = mysql_query("SELECT ArticleID FROM test_top ORDER BY ArticleID ASC LIMIT 1") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $ArticleID=$row['ArticleID']; } $ArticleID=intval($ArticleID); $ArticleID++; --- Hello all, I am new to php coding and have a couple of problems with editing records in my database! I have two files below one test.php and edit.php. In the test.php the code outputs the records into a table. The problem is with the edit link as when it is selected I wish to be able to edit a record by a form, which is on edit.php. I am trying bring up the movie's information on the form to be edited. Currently on the form i get; Quote Movie: movie Gen Genre Year: year Any ideas how I can edit the record and then return to the test.php page? Code: [Select] test.php <html> <body style="background-color:#669999;"> <table width="490"border=0><tr> <td colspan="2" style="background-color:#FFA500;"> <div id="header" <h3 style="color:black">This is my first web-page! Below is a database of some of my favourite movies! </h3> </td> </tr> <?php //connecting to server $con = mysql_connect("localhost","root","NYOXAkly"); if (!$con) { die('could not connect: ' . mysql_error()); } //selecting movie database mysql_select_db("my_mov",$con); //Check if add button is active, start this if(isset($_REQUEST['add'])) { echo "<meta http-equiv=\"refresh\"content=\"0;URL=form.php\">"; } $result = mysql_query("SELECT * FROM Films ORDER BY filmID"); ?> <!-------------------------------creating table------------------------------------------------------------------------------------> <table width="490" border="0" cellspacing="1" cellpadding="0"> <tr> <td> <form name="test1" method="post" action="test.php"> <table width="490" border="10" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"><tr> <td bgcolor="#FFFFFF"></td> <td align="center" colspan="6" bgcolor="#FFFFFF">Movie Database</td></tr> <td align="center" bgcolor="#FFFFFF">filmID</td> <td align="center" bgcolor="#FFFFFF">Movie</td> <td align="center" bgcolor="#FFFFFF">Genre</td> <td align="center" bgcolor="#FFFFFF">Year</td> <td align="center" bgcolor="#FFFFFF">Edit</td> <td align="center" bgcolor="#FFFFFF">Delete</td> </tr> <?php while($rows=mysql_fetch_array($result)) { ?> <tr> </td> <td bgcolor="#FFFFFF"><? echo $rows['filmID']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['movie']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['genre']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['year']; ?></td> <td bgcolor="#FFFFFF"> <a href="edit.php?filmID=<?php echo 'filmID';?>">Edit</a> <td bgcolor="#FFFFFF"> <a href="delete.php?filmID=<?php echo 'filmID';?>">Delete</a> </td> </tr> <?php } echo print_r(error_get_last()); mysql_close(); ?> <!--add button--> <tr> <td colspan="15" align="left" bgcolor="#FFFFFF"> <input name='add' type="submit" filmID="add" value="Add A New Record" action="form.php?"> </td> </tr> </table> </form> <br/> By C.M.D.W <br/> <?php echo date("Y/m/d") . "<br />"; ?> </body> </html> Code: [Select] edit.php <html> <body style="background-color:#669999;"> <!------------------Creates a form ----------------------> <br /> <form action="" method="post"> <fieldset> <legend>Enter your movies into database here!</legend> Movie: <input type ="text" name="movie" value="<?php echo 'movie';?>"> <br /> Gen <input type ="text" name="genre" value="<?php echo 'genre';?>"/> <br /> Year: <input type ="text" name="year" value="<?php echo 'year';?>"/> <br /> <input type="submit" name="name" value="Submit" /> </fieldset> </form> <?php //connecting to server $con = mysql_connect("localhost","root","NYOXAkly"); if (!$con) { die('could not connect: ' . mysql_error()); } //selecting movie database mysql_select_db("my_mov",$con); if (isset($_POST['submit'])) { // confirm that the 'id' value is a valid integer if (is_numeric($_POST['filmID'])) // get form data $filmID = $_POST['filmID']; $movie = mysql_real_escape_string(htmlspecialchars($_POST['movie'])); $genre = mysql_real_escape_string(htmlspecialchars($_POST['genre'])); $year = mysql_real_escape_string(htmlspecialchars($_POST['year'])); // check that fields are filled in if ($movie == '' || $genre == '' || $year == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; } else { // save the data to the database } mysql_query("UPDATE players SET movie='$movie', genre='$genre', year='$year' WHERE filmID='$filmID'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: test.php"); } } if (isset($_GET['filmID']) && is_numeric($_GET['filmID']) && $_GET['filmID'] > 0) { // query db $id = $_GET['filmID']; $result = mysql_query("SELECT * FROM Films WHERE filmID=$FilmID") or die(mysql_error()); $row = mysql_fetch_array($result); // check that the 'id' matches up with a row in the databse if($row) { // get data from db $movie = $row['movie']; $genre = $row['genre']; $year = $row['year']; }} ?> <br/> <br/> <a href="test.php">Return To Home Page</a> <br/> <br/> By C.M.D.W <br/> <?php echo date("Y/m/d") . "<br />"; ?> </body> </html> Thanks Chris Hi guys, I am trying to UPDATE some records on a mySQL database but can't seem to find out why it is not working. This is my code. Code: [Select] <?php $latitude = $_POST['lat_location']; $longitude = $_POST['long_location']; $unique_ID = $_POST['unique_ID']; include('connect2.php'); $query = mysql_query("SELECT * FROM user_location WHERE unit = '$unique_ID'"); $numrows = mysql_num_rows($query); if ($numrows == 1) { $query2="UPDATE user_location SET lat = '$latitude', long = '$longitude' WHERE unit = '$unique_ID'"; mysql_query($query2); $test = "matches"; } else { mysql_query("INSERT INTO user_location VALUES ('','$unique_ID','$latitude','$longitude')"); $test = "not match"; } echo $test . "<br />"; echo $numrows; ?> The script receives the data via the POST method and assigns it to variables. Then I query the database for one of those variables and check how many results are found. If 0 results are found then a new record is created on the database, but if there is 1 record found then the record that is found has to be UPDATED. When the result is 0 the scripts creates the new record fine, but if the result is 1 it doesn't update. I just can't figure out why. Any help will be greatly appreciated. Thanks in advanced, Hello, This is driving me crazy, as I cannot get it working. I have a database that has a table called 'categories'. I need to retrieve all categories with category_id != '1,2,3'. For this, I can this query: Code: [Select] $q = "SELECT * FROM categories WHERE category_id NOT IN (1,2,3)"; The query executes fine. I need this categories retrieved, to be passed to a Smarty Template Engine powered page. I have: Code: [Select] $q = "SELECT * FROM categories WHERE category_id NOT IN (1,2,3)"; $res = mysql_query($q); while($row=mysql_fetch_array($res)) { Assign('categories',$row); } But when retrieving the array in the Smarty page, with a loop, I only see the last item of the array (the last category). If I go back to the while loop, and add a Code: [Select] print_r($row);, I see two arrays (I have two categories). But the question is: How can I work with those two categories, as I need to use them individually outside the while loop? Any help is appreciated. Best Regards, Richi I have a problem . I 've been trying for a long time to make an update for php mysql to change the data. but every time I do not manage to make it work with a form. but it works if I only if I put this ($ sql = "UPDATE users SET username = 'value' WHERE id = 10 " ; ) so it only works when I put the value of the id. but I want in an html form to indicate what I want to change and what id goes. but I have tried so long that I do not feel like I so want someone help me. make the same database and same as my records and make the code and test it if it works show me please my database name : web test my table called : users my records are called : id int ( 11) AUTO_INNCREMENT username , varchar ( 255 ) password , varchar ( 255 ) first_name , varchar ( 255 ) last_name , varchar ( 255 ) email, varchar ( 255 ) Age, int ( 11) Look, my update.php is like this now <?php $servername = "localhost"; $username = "root"; $password = "....."; $dbname = "webtest"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE users SET password='cotton candy' WHERE id=10"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?> but now i have still have to go into the php file to change the valeu or the id but i looked on site and youtube how to put it in a simple html form but it still does not work. i want it in a html from. I want that when I enter the ID that the data of the user appears and that I can change any valeu separately. Hi guys, I need your help. I am checking on a database as I want to see if the records have been updated or not. Code: [Select] <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbtable'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $username = clean($_GET['user']); $password = clean($_GET['pass']); $test = clean($_GET['test']); $public = clean($_GET['public']); if (isset($_GET['user']) && (isset($_GET['pass']))) { if($username == '' || $password == '') { $errmsg_arr[] = 'username or password are missing'; $errflag = true; } } elseif (isset($_GET['user']) || (isset($_GET['test'])) || (isset($_GET['public']))) { if($username == '' || $test == '' || $public == '') { $errmsg_arr[] = 'user or others are missing'; $errflag = true; } } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qry="SELECT * FROM members WHERE username='$username' AND passwd='$password'"; $result=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if ($username && $password) { if(mysql_num_rows($result) > 0) { $qrytable1="SELECT images, id, test, links, Public FROM user_channel_list WHERE username='$username'"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "<p id='test'>"; echo $row['test'] . "</p>"; echo '<p id="images"> <a href="images.php?test=test&id='.$row['id'].'">Images</a></td> | <a href="http://' . $row["links"] . '">Link</a> </td> | <a href="delete.php?test=test&id='.$row['id'].'">Delete</a> </td> | <span id="test">'.$row['Public'].'</td>'; } } else { echo "user not found"; } } elseif($username && $test && $public) { $qry="SELECT * FROM members WHERE username='$username'"; $result1=mysql_query($qry) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result1) > 0) { $qrytable1="SELECT Public FROM user_channel_list WHERE username='$username' && test='$test'"; $result2=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); if(mysql_num_rows($result2) > 0) { $row = mysql_fetch_row($result2); mysql_query("UPDATE user_list SET Public=('$_GET[public]') WHERE username='$username' AND test='$test'"); echo "update!"; } else { echo "already updated!"; } } else { echo "user not found"; } } } ?> When I run debug the code on my php, if i input the data in a url bar while the records are the same as the data that I enter in the url, i should get the print out on my php "already updated", but I keep getting "update!". Do you know how i can check on mysql database to see if the records have been updated or not?? Hi,I'm hoping someone can help me:). When I add foreign keys to the database in MySQL I CAN change the primary key field and the corresponding indexed field will automatically change giving me the same value which is exactly what i want. The issue is when I try to insert the values using my php code i get the 'cannot update child error'. I have not selected a value for the unique_id field as I want it to inherit the value from the primary key. Here's my code as simplified as I could do it. <?php //this calls the class productupload and instantiates the function insert_form to insert values into the db. $product = new productUpload(); $product->insert_form();?> //This calls the insert_form function and inserts info into tables <?php class productUpload extends DatabaseObject{ protected static $table_name="itm_details"; protected static $db_fields =array('id','unique_id','itm_cat','itm_make','itm_model','itm_desc','itm_cond','itm_date_from','itm_date_to','itm_add_date'); public $id; public $unique_id; public $itm_cat; public $itm_make; public $itm_model; public $itm_desc; public $itm_cond; public $itm_date_from; public $itm_date_to; public $itm_add_date; Heres the function insert_form which grabs the form submitted data. Note I have not defined a value for $unique_id public function insert_form(){ global $database; //set the object attributes to the form the parameters if(isset($_POST['submit'])) { $result = array( $this->itm_cat =(!empty($_POST['itm_cat'])) ? trim($_POST['itm_cat']) : NULL, $this->itm_make =(!empty($_POST['itm_make'])) ? trim($_POST['itm_make']) : NULL, $this->itm_model = (!empty($_POST['itm_model'])) ? trim($_POST['itm_model']) : NULL, $this->itm_desc =(!empty($_POST['itm_desc'])) ? trim($_POST['itm_desc']) : NULL, $this->itm_cond =(!empty($_POST['itm_cond'])) ? trim($_POST['itm_cond']) : NULL, $this->itm_date_from =(!empty($_POST['itm_date_from'])) ? trim($_POST['itm_date_from']) : NULL, $this->itm_date_to =(!empty($_POST['itm_date_to'])) ? trim($_POST['itm_date_to']) : NULL, $this->itm_add_date = date("Y-m-d H:m:s")); //check date is numeric //if(is_numeric($_POST['itm_date_from'])) { //$this->itm_date_from = $_POST['itm_date_from']; //} //check date is numeric //if(is_numeric($_POST['itm_date_to'])) { //$this->itm_date_to = $_POST['itm_date_to']; //} if($result){ $result = $this->create(); } } } //here's the create function referred to above which sanitises the posted data and inserts it into the db. public function create() { global $database; $attributes = $this->sanitised_attributes(); $sql = "INSERT INTO ".self::$table_name."("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)) { $this->id = $database->insert_id(); return true; } else { return false; } } I'm sorry to be back so soon, but I'm up against another mystery. I'm using the code below to enter a bunch of css data from a spreadsheet into a mysql table. I think the data file is OK. The array created by the script checks out with print_r. (There are many more records than shown. I truncated it to save space.) The problem is that I get this error regarding my sql statement, not the data or anything else: Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'check, name, phone, email, entry_fee, print_fee, image_name, description, med...' at line 1 in /Users/studio/Sites/BannerProject/b-as/_test_site/csv_to_array.php:242 Stack trace: #0 /Users/studio/Sites/BannerProject/b-as/_test_site/csv_to_array.php(242): PDO->prepare('INSERT INTO tbl...') #1 {main} thrown in /Users/studio/Sites/BannerProject/b-as/_test_site/csv_to_array.php on line 242 I've typed it in a dozen times to make sure there are no errors and keep getting the same error. I tried running a test file and gradually increasing the number of placeholders and at some point I always end up getting the same error, I can delete the most recent addition and it works again. Then I can add another placeholder exactly as before and it works the second time. It feels like a ghost in the machine. Any idea what I am doing wrong? An I typing something I don't see? <?php require '__classes/Db.php'; $csvData = '1,FALSE,Carol Lettko,,,TRUE,FALSE,Carol_Lettko-DSC_3022.jpg,Baby Herons/Brickyard,photo,,, ,,,925-285-0320,cjl164@aol.com,,,Carol_Lettko-DSC_0164.JPG,Heron/Brickyard,photo,,, ,,,,,,,Carol_Lettko-IMG_5723.jpg,Kayaker/Brickyard,photo,,, ,,,,,,,,,,,, 2,FALSE,Louise Williams,,,TRUE,FALSE,Louise_Williams-BirdsOfAFeatherAOPR.jpg,Alligator with Words,Book Excerpt,,, ,,,510-232-9547,lkw@louisekwilliams.com,,,Louise_Williams-Hope-TheFairyChickenAOPR.jpg,Hope The Fairy Chicken,,,, ,,,The d exatrfrfvct/.*tygrvurr,,,,,,,,, ,,,,,,,,,,,, 3,TRUE,Dorothy Leeland,,lelanddorothy@gmail.com,TRUE,FALSE,DJ_Lee-bridge at dusk 700px width.jpg,Bridge,photo,,, ,,,,,,,DJ_Lee-friends 700px width.jpg,Friends,photo,,, ,,,,,,,DJ_Lee-hybiscus 700 px wide.jpg,Hibiscus,photo,,, ,,,,,,,,,,,, 4,FALSE,Rita Gardner,,,TRUE,FALSE,Rita_Gardner-Explosion - Gardner photo.JPG,Explosion,photo,,, ,,,,tropicrita@msn.com,,,Rita_Gardner-Ferry Point tables and chair - Gardner.JPG,Ferry Point Tables,photo,, , ,,,,,,,Rita_Gardner-Forks - Gardner photo.JPG,Forks,photo,,, ,,,,,,,,,,,, '; $lines = explode(PHP_EOL, $csvData); $array1 = array(); foreach ($lines as $line) { $array1[] = str_getcsv($line); } $stmt = $pdo->prepare("INSERT INTO tbl_person_data (number, check, name, phone, email, entry_fee, print_fee, image_name, description, medium, select, orient, site) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"); foreach ($array1 as $row) { $stmt->execute('$row'); } echo '<pre>'; print_r($array1); echo '</pre>'; ?>
I am reading in a table and ordering it by a column labeled "sub" and generating an HTML table. The "sub" column entries are in numerical order (i.e. 1 2 3 4 5 6 7 8 10 11 12 etc. etc.). There are over 100 entries in this table as well. The problem I'm facing is probably obvious to some of you as the display is
1 Obviously I'd like the display to be in numerical order.
What can I do?
I have a normalized database in the form of Code: [Select] ID user_id key value 1 3 first_name Brian 2 3 last_name Tardy 3 4 first_name John 4 4 last_name Wilson What is the fastest way to capture these values within php? I want to perform a SELECT to catch the values for every user as Code: [Select] $result=mysql_query("SELECT * FROM users_data WHERE user_id = '$id'"); while($row=mysql_fetch_array($result)) { here we process all data for a given user and write it to text file as a single line } Since it is a long list (100K users with about 10M of rows in user_data), I am looking for the fastest and most reliable way to scan all the database. ?> I wonder whether someone can help me please. I've found http://www.plus2net.com/php_tutorial/ajax-listbox.php tutorial to create a drop down menu using mySQL table data, which, in turn returns a list of results on the page. Following this tutorial I've put together the tables in my database and the required scripts as shown in the tutorial with the one exception, the "z_db.php" file, which I've assumed to be: Code: [Select] <?php mysql_connect("host", "user", "password")or die(mysql_error()); mysql_select_db("database"); ?> The problem I have, is that when I try and run this, I receive the following error: Quote Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/2/d333603417/htdocs/development/catsearch.php on line 91 which is this line in the search form: echo "</head><body onload="ajaxFunction()";>";. I must admit I've guessed as to the structure of the 'z_db.php' file should look like because this is not shown so perhaps this is the problem. I just wondered wether someone could perhaps take a look at this please and let me know where I've gone wrong. Many thanks and kind regards Hi, I'm new to the forum so this could go in the MySQL section but I'm not sure. I am trying to make a page that will list all records from a column in HTML table and have a delete button to remove a specific record. I have got to the part where I have listed the records in a table. Note: Only records from a specific column ('links') are printed. Here is the code: Code: [Select] $con = mysql_connect("localhost","***","***"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("***", $con); $result = mysql_query("SELECT * FROM main"); echo "<table border='1'> <tr> <th>Current links</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['links'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); How would I go about adding a delete button next to each record to delete that specific record? Thanks for any help. How do you do this? Thanks in advance. Code: [Select] <?php require "db/config.php"; $fname = $_POST['fname']; $lname = $_POST['lname']; $country = $_POST['country']; $state = $_POST['state']; $city = $_POST['city']; $zcode = $_POST['zcode']; $address = $_POST['address']; $ppemail = $_POST['ppemail']; $pnumber = $_POST['pnumber']; $cemail = $_POST['cemail']; $url = $_POST['url']; $price = "$5.00"; $query = "INSERT INTO custpackage1000( id, FirstName, LastName, Country, State, City, ZipCode, Address, PayPalEmail, PhoneNumber, PrimaryEmail, WebsiteURL) VALUES ( '1', '$fname', '$lname', '$country', '$state', '$city', '$zcode', '$ppemail', '$pnumber', '$cemail', '$url')"; mysql_connect($host, $user, $pass) or die("<br /><br /><h1>Fatal error. Please contact support if this persists.</h1>"); mysql_select_db($dbname); mysql_query($query) or die ("could not open db".mysql_error()); sleep(2); ?> Why won't the code insert into my database upon submission of data? What am I doing wrong? I have news articles which I distribute to various sites. Each article contains various hyperlinks, which must resolve to a location on the site which pulled the article, i.e. Article: (hyperlink) Widgets are wonderful. Don Doe, president of (Widgets Incorporated) say they are cool. ------ Site A: To resolve to example.com/widget-companies/Widget-news/Widgets-Incorporated. Site B: To resolve to otherexample.com/Widgets-Incorporates/widget-news I'm paralyzed. The only thing I can think of is to bring the whole article in, and do a string replace. Some of the articles are 2k+ words. Even then, I have to come up with a way of pointing out the link text. I came up with $COMPANY:WIDGETS-INCORPORATED:Widget-Incorporated (UC WIDGETS to associate it with that company, and the mixed case Widget-Incorporated would be the hyperlink text. Explode it and use it. I am not even sure it will work, or if it works whether it is too inefficient. Should I try that, or something else? Hello
Is it possible to save data from saved htm table from other website in our mysql database system
as I have problem that there is one htm page where i can get data but i want to save it in mysql table. as data is large on htm page
it was hard to copy so i want access it direct from php and save it in mysql table
please guide
awaiting your valuable reply.
Thank in advance
I want to pull some records plus unique key from one mysql table and then use them as questions in a form/questionnaire. The post form will have six radio buttons to the right of the fields pulled with the key posted but hidden and will wirte to another table. I guess this is a templating question- as I've successfully retrieved the table 1 records via a query - I just can't seem to use them in the form. Below is the code I'm using to view table "PCM1" <?php // query.php require_once 'login.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); $query = "SELECT * FROM pcm1"; $result = mysql_query($query); if (!$result) die ("Database access failed: " . mysql_error()); $rows = mysql_num_rows($result); for ($j = 0 ; $j < $rows ; ++$j) { echo 'RID: ' . mysql_result($result,$j,'mcde') ; echo 'Statement: ' . mysql_result($result,$j,'oppclub') . '<br />'; ; } |