retrieving all information from a single table

From: Date: Fri, 21 Jun 2002 22:27:53 +0000
Subject: retrieving all information from a single table
Groups: php.db 
Request: Send a blank email to php-db+get-19985@lists.php.net to get a copy of this message
Hello everyone, I am brand new to php, so any replies I get are very much appreciated. My goal is to retrieve one entire table from my database and post the information on the web. My query seems successful, but I am having trouble getting the information out from the variable $result. My table has 4 fields, the primary key, "location," "organization," and "charge." Any suggestions? A million thanks. Here is the code: <html> <body> <? /* Connectiong*/ @ $db = mysql_connect("localhost", "NAME","PASS"); if (!$db) { echo "Error, please try again."; exit; } /* Selecting database*/ $db2 = mysql_select_db ("DATABASE"); if (!$db2) { echo "error again"; exit; } /*sending query */ $query = "select * from $mytable where $i"; $result = mysql_query($query); /*testing to see if result has the data */ if (!$result){echo "result is empty";} for ($a=0;$a<4;$a++) { for($i=0;$i<4;$i++) { $row = mysql_fetch_array($result); echo $row[i]["organization"]."<br>"; echo $row[i["location"]."<br>"; echo $row[i]["charge"]; } } ?> </body> </html> -- Jonathan

« previous php.db (#19985) next »