php-doc-en/reference/msql/examples.xml
Hannes Magnusson 3f5cfc0b6a MFB: Upgrade to the new-reference-structure
- (Created missing setup sections in setup.xml, if any)
 - Moved the intro to book.xml
 - Changed the intro ID from <extname>.intro to intro.<extname>
 - Moved the constants entity to book.xml
 - Changed constants.xml to be an appendix
 - Moved the example to its own chapter (examples.xml)
    NOTE: The chapter ID is msql.examples
          the orginal msql.examples section was renamed to msql.examples-basic
 - Moved the configure & ini entities to setup.xml
 - Moved the resources section to setup.xml


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@249007 c90b9560-bf6c-de11-be94-00142212c4b1
2007-12-26 13:55:58 +00:00

71 lines
1.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<chapter xml:id="msql.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="msql.examples-basic">
<para>
This simple example shows how to connect, execute a query, print
resulting rows and disconnect from a mSQL database.
<example>
<title>mSQL usage example</title>
<programlisting role="php">
<![CDATA[
<?php
/* Connecting, selecting database */
$link = msql_connect('localhost', 'username', 'password')
or die('Could not connect : ' . msql_error($link));
msql_select_db('database', $link)
or die('Could not select database');
/* Issue SQL query */
$query = 'SELECT * FROM my_table';
$result = msql_query($query, $link) or die('Query failed : ' . msql_error());
/* Printing results in HTML */
echo "<table>\n";
while ($row = msql_fetch_array($result, MSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($row as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/* Free result set */
msql_free_result($result);
/* Close connection */
msql_close($link);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->