cvs: phpdoc /en/functions mysql.xml

From: Date: Sat, 17 Nov 2001 11:31:22 +0000
Subject: cvs: phpdoc /en/functions mysql.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969338937@lists.php.net to get a copy of this message
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"> -&lt;?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 "&lt;table&gt;\n"; - while ($line = mysql_fetch_array($result)) { - print "\t&lt;tr&gt;\n"; - while(list($col_name, $col_value) = each($line)) { - print "\t\t&lt;td&gt;$col_value&lt;/td&gt;\n"; - } - print "\t&lt;/tr&gt;\n"; - } - print "&lt;/table&gt;\n"; - - mysql_close($link); -?&gt; +// 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>

« previous php.doc (#969338937) next »