More correct example, applying PEAR code standars,

and using CDATA to ease the work of manual people ;)


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@62630 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Gabor Hojtsy 2001-11-17 11:31:21 +00:00
parent d410f85ef7
commit 57df7bc396

View file

@ -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>