goba Sat Nov 17 06:31:22 2001 EDT
Modified files:
/phpdoc/en/functions mysql.xml
Log:
More correct example, applying PEAR code standars,
and using CDATA to ease the work of manual people ;)
Index: phpdoc/en/functions/mysql.xml
diff -u phpdoc/en/functions/mysql.xml:1.70 phpdoc/en/functions/mysql.xml:1.71
--- phpdoc/en/functions/mysql.xml:1.70 Fri Nov 16 17:29:07 2001
+++ phpdoc/en/functions/mysql.xml Sat Nov 17 06:31:21 2001
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.70 $ -->
+<!-- $Revision: 1.71 $ -->
<reference id="ref.mysql">
<title>MySQL Functions</title>
<titleabbrev>MySQL</titleabbrev>
@@ -32,31 +32,35 @@
<example>
<title>MySQL extension overview example</title>
<programlisting role="php">
-<?php
- $link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
- or die ("Could not connect");
- print ("Connected successfully");
- mysql_select_db ("my_database")
- or die ("Could not select database");
-
- $query = "SELECT * FROM my_table";
- $result = mysql_query ($query)
- or die ("Query failed");
+<![CDATA[
+<?php
+// Connecting, selecting database
+$link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
+ or die("Could not connect");
+print "Connected successfully";
+mysql_select_db("my_database")
+ or die("Could not select database");
- // printing HTML result
+// Performing SQL query
+$query = "SELECT * FROM my_table";
+$result = mysql_query($query)
+ or die("Query failed");
- print "<table>\n";
- while ($line = mysql_fetch_array($result)) {
- print "\t<tr>\n";
- while(list($col_name, $col_value) = each($line)) {
- print "\t\t<td>$col_value</td>\n";
- }
- print "\t</tr>\n";
- }
- print "</table>\n";
-
- mysql_close($link);
-?>
+// Printing results in HTML
+print "<table>\n";
+while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
+ print "\t<tr>\n";
+ foreach ($line as $col_name => $col_value) {
+ print "\t\t<td>$col_name</td><td>$col_value</td>\n";
+ }
+ print "\t</tr>\n";
+}
+print "</table>\n";
+
+// Closing connection
+mysql_close($link);
+?>
+]]>
</programlisting>
</example>
</para>