mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
d410f85ef7
commit
57df7bc396
1 changed files with 28 additions and 24 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue