mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Turned ?> -> ?>
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@48749 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
c7c95d0ebb
commit
077741678f
1 changed files with 46 additions and 13 deletions
|
@ -24,7 +24,40 @@
|
|||
Documentation for MySQL can be found at <ulink
|
||||
url="&url.mysql.docs;">&url.mysql.docs;</ulink>.
|
||||
</simpara>
|
||||
<para>
|
||||
This simple example shows how to connect, execute a query, print
|
||||
resulting rows and disconnect from MySQL Database.
|
||||
<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");
|
||||
|
||||
// printing HTML result
|
||||
|
||||
print "<table>\n";
|
||||
while($line = mysql_fetch_array($result, MYSQL_){
|
||||
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);
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</partintro>
|
||||
|
||||
<refentry id="function.mysql-affected-rows">
|
||||
|
@ -176,7 +209,7 @@
|
|||
or die ("Could not connect");
|
||||
print ("Connected successfully");
|
||||
mysql_close ($link);
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -311,7 +344,7 @@
|
|||
} else {
|
||||
printf ("Error creating database: %s\n", mysql_error ());
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -380,7 +413,7 @@
|
|||
}
|
||||
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -562,7 +595,7 @@ mysql_select_db("nonexistentdb");
|
|||
echo mysql_errno().": ".mysql_error()."<BR>";
|
||||
$conn = mysql_query("SELECT * FROM nonexistenttable");
|
||||
echo mysql_errno().": ".mysql_error()."<BR>";
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -611,7 +644,7 @@ mysql_select_db("nonexistentdb");
|
|||
echo mysql_errno().": ".mysql_error()."<BR>";
|
||||
$conn = mysql_query("SELECT * FROM nonexistenttable");
|
||||
echo mysql_errno().": ".mysql_error()."<BR>";
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
@ -718,7 +751,7 @@ while ($row = mysql_fetch_array ($result)) {
|
|||
echo "fullname: ".$row[1]."<br>\n";
|
||||
}
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -777,7 +810,7 @@ while ($row = mysql_fetch_assoc ($result)) {
|
|||
echo $row["fullname"];
|
||||
}
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
@ -910,7 +943,7 @@ zerofill: $meta->zerofill
|
|||
$i++;
|
||||
}
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
|
@ -1003,7 +1036,7 @@ while ($row = mysql_fetch_object ($result)) {
|
|||
echo $row->fullname;
|
||||
}
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1278,7 +1311,7 @@ while ($i < $fields) {
|
|||
}
|
||||
mysql_close();
|
||||
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1749,7 +1782,7 @@ echo "$num_rows Rows\n";
|
|||
<?php
|
||||
$result = mysql_query ("SELECT * WHERE 1=1")
|
||||
or die ("Invalid query");
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1764,7 +1797,7 @@ $result = mysql_query ("SELECT * WHERE 1=1")
|
|||
<?php
|
||||
$result = mysql_query ("SELECT my_col FROM my_tbl")
|
||||
or die ("Invalid query");
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -1972,7 +2005,7 @@ while ($i < mysql_num_rows ($result)) {
|
|||
echo $tb_names[$i] . "<BR>";
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue