“MySQL的分类归档

PHP MySQL教程

出版日期:2010年10月14日,
标签:
影片预览图像

“MySQL的分类归档

PHP MySQL教程

出版日期:2010年10月14日,
标签:

一个和唯一的数据库管理程序的Internet主机的客户将不断学习是我的SQL。 为什么如此众多的世界各地的网络主机提供MySQL的原因可能会被进一步解释如下。 与其他的DMS的MySQL频繁使用的SQL语言,今年只是单一亿美元购买由Sun Microsystems。

一个开源软件计划

一个人是最强MySQL的优势 ,敞开供应编程的数据库管理技术。 这并不意味着,然而,它应该被视为免费。 没有,还是有这个计划了多项专利功能,它的成本和现金使用。 但允许它的用户一个自由的肯定,因为他们认为合适的修改DBMS建设作为一个开放的供应计算机软件的MySQL。 根据通用公共许可证的MySQL授权有一个开放的供应代码和软件程序分发到客户许可证,让他们有权查看,修改和提高资源的代码,从而软件包。 这是一个人为什么MySQL已经变成这样大大众所周知的原因。

快速更新和友好人士

当其他数据库管理系统,如Oracle缓慢更新的MySQL很少让他们的客户等待。 有了新的升级版本往往比作为主服务器数据库的初始位置,它看起来像MySQL已经发现它的地方。 已知和主要使用Linux的手术方案,恰好是网服务器的首选手术方法,MySQL是快速和可靠的。

的cPanel,phpMyAdmin和MySQL的

初学者的平台,利用数据库的一个很好的例子是许多Internet主机正在使用的cPanel控制面板。 不仅人有,为了创建数据库访问视频教程,但phpMyAdmin 功能,为用户提供视觉辅助管理MySQL的许多任务。 此外,MySQL的存在使许多字宽网络主机提供PHP脚本,使发展动态的应用,为他/她的网页的人

“MySQL的分类归档

PHP MySQL教程

出版日期:2010年10月14日,
标签:

1) 华人协会IDX的网页设计

ccca 基于PHP和 MySQL的内容管理系统。 强大而又简单的CMS。 全面的功能。 定价似乎是合理的小公司。 易于安装和用户友好。 仅适用于所有可用的IDX的网页设计客户。 联系IDX的网页设计,并要求报价

2) JOOMLA WILCO扬森

joomla-s-webtreatsetc-128 屡获殊荣的内容管理系统(CMS),它使您能够建立网站和功能强大的在线应用。 许多方面,包括其易于使用和可扩展性, 使 Joomla提供最流行 ​​的网站软件。 最好的是,Joomla是一个开放源码的解决方案,是免费提供给大家。

3)由瑞安 WordPress的 博伦

wordpress-logo 国家最先进的重点是美学,Web标准和可用性的信息发布平台。WordPress的是在同一时间既自由,又无价。
WordPress是更简单,你用什么,当你想与您的博客软件,不打它。

4) Soholaunch

soholaunch 一个易于使用网页制作工具来帮助您建立,维护和管理您的个人或商业网站。 它运行的权利从您的网站,很容易采取网上购物车订单,创建形式,从世界的任何计算机和编辑网站页面!

5) Drupal的

drupal-s-webtreatsetc-128 一个免费的软件包,使用户的个人或社区轻松地发布,管理和组织各种网站上的内容。 数以万计的个人和组织采用Drupal的不同网站的权力分数

“MySQL的分类归档

PHP MySQL教程

出版日期:2010年10月14日,
标签:

我们需要做的第一件事是连接到数据库。

mysql_connect("somehost", "username", "password") or die ("Can't connect!");

This will try to connect to the database on somehost and login with “username” as the username and “password” as the password. If it can’t, it will output an error message saying that it can’t connect. For your own code be sure to change somehost to your host (most of the times it’s localhost, ask your admin), username to your username (duh), and password to your password. Another way to connect to a database is to open a persistent connection. To do this, use the mysql_pconnectfunction and pass it the same arguments as mysql_connect. Why open a persistent connection? When you call mysql_pconnect, instead of going out and opening a connection to the database, it sees if one is already open, if it is, the script will use it. Also, when the script has finished executing, the connection to the database will not automatically be closed like it is when using mysql_connect. This way the connection can be used later on. Using a persistent connection is a good idea if your scripts constantly need to connect to the database.

After we have opened a connection to the database, we then select a database.

mysql_select_db("database_name") or die("Can't select database!");

This will try to select the database named “database_name” (for your own code change it to the name of your database). If it can’t select the database, it will output and error. Once you’re actually connected to a database, you will want to query a table in the database to get whatever you want done. A query looks like this:

mysql_query("Some query");

Common queries are SELECTand INSERT For full documentation go to the mysql web site ( http://www.mysql.com ). Another common php function is mysql_num_rows; if it isn’t obvious this gets the number of rows from a query. Here is an example of how it can be used with mysql_query:

<?php

  $result= mysql_query("SELECT * FROM some_table");

  $number_of_rows= @mysql_num_rows($result);

  if ($number_of_rows == 0)

  {

    echo "Sorry there are no rows";

  }

  else {

    echo "Yes! we found some rows!";

  }

?>

Now you may be wondering why I put the @ sign before mysql_num_rows. In php, the @ sign suppress errors; I put it in front of mysql_num_rows so that if there are no rows, MySQL will not output a bunch of errors. So when would mysql_num_rows be useful? Well, you could use it for an authentication script which searchs the database for a username and password and if it doesn’t find any (i.e. if no rows are returned), it tells the user that the username, or password, are not correct.

Another really useful function is mysql_fetch_array, because it gets the rows and puts them in an array that contains the name of the rows. That way instead of having to access each row by number you can do it by name! For example, let’s say that our database looked like this:

User Password
John afasdfadsfdsf
Billy tla;jrjealjwqsldajf
Mitch pqrtupipripewir

We would use the following code to get the users’ names and output them:

<?php

  echo "The users in this database are: <br>";

  $result= mysql_query("SELECT * FROM some_table");

  while ($row= mysql_fetch_array($result))

  {

    $username= $row["User"];

    echo "$username<br>";

  }

?>

This will output all the usernames in a database; you can add error checking if you like. The while statement is read “while there are rows that satisfy the query, put the contents of the row from the column ‘User’ into the variable ‘username,’ and print the usernames (each on a new line) to an HTML page.”

Now let’s cover a couple of functions that actually work with the database. The first is mysql_create_db, don’t you just love how the functions are named you can figure out what they do just by looking at the function name, this one obviously creates a database. Here’s how to use it:

<?php

  echo "I am going to try to create a database...<br>";

  if (mysql_create_db("test_database"))

  {

    echo "Hooray, I've created the database!<br>";

  }

  else {

    echo "Darn couldn't create the database! because: ";

    echo "mysql_error() <br>";

  }

?>

You can see I used a new function, mysql_error, you don’t really need to know too much about it, all it does is return the error string sent by MySQL. Now since we learned how to create a database, how’s about we learn to delete one. To do that use the mysql_drop_db, here is how to use it:

<?php

  echo "I am going to try to delete a database...<br>";

  $result= mysql_drop_db("test_database");

  if (!$result)

  {

    echo "Darn couldn't I couldn't delete the database!<br>";

  }

  else {

    echo "Hooray, I've deleted the database<br>";

  }

?>

You can see that the syntax is very similar to that of mysql_create_db, just pop the name of the database you want to delete into the function.

The next two items aren’t functions, rather they are queries that you can use to manage an existing table. The following query will insert data into a database:

<?php

  echo "I am going to try to insert data into a table...<br>";

  $result= mysql_query("INSERT INTO test_database (username, password) VALUES

	               (Rahim, adfjaldadfsdaf)");

  if (!$result)

  {

    echo "Darn couldn't I couldn't delete the database!<br>";

  }

  else {

    echo "Hooray, I've deleted the database<br>";

  }

?>

This query should be pretty obvious, it inserts the data defined in between the parentheses into the rows. Just a little note to remember, the order in which you write out the column names is the order your data will be entered (i.e. a row with the contents Rahim will be entered under username, not password since we wrote username then pasword, if it was reveresd Rahim would be put under password).

The next query we’ve already gone over, I’m just going to add to it; after I’m done you should be able to use it to help create a simple search engine (upcomming tutorial)! For the sake of brevity I’ll remove all the extra php stuff and just show you the “meat” of the code.

$result= mysql_query("SELECT name FROM some_table WHERE name=Joe AND

         lastname=Sixpack OR lastname=Becker ORDER BY lastname LIMIT 20");

Now I know that looks like a long query, but it’s not really all that bad. What it’s pretty much saying is: “Get me the name from some_table where the name is Joe and the lastname is Sixpack or Becker, oh and by the way while your at it, put it in alphabetical order by the lastname; oh and one last thing, just get the first 20 results please.” MySQL has lots of other filters that you can add on to the SELECT statement, I highly suggest you download the MySQL documentation and give it a perusing.

 

Translator

English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flag
Arabic flagGreek flagDutch flagBulgarian flagCzech flagCroatian flagDanish flagFinnish flagHindi flagPolish flag
Romanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flag
Slovak flagSlovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flagTurkish flag
Hungarian flag         

My Partners

审查rockyrasonable.com在alexa.com

HostGator的
HostGator的 templateplazza elegantthemes rockettheme TopPhilippineWebsites.com 网志串连中心编程

Tags

获取Adobe Flash Player Plugin by wpburn.com wordpress themes

Powered by WP Robot