header("Content-Type:text/html;charset=UTF-8"); $conn = mysql_connect('localhost','root','');//链接服务器(非永久性) if(!$conn){ echo '
'; die('error:'.mysql_error()); }else{ echo '
'; echo '链接服务器:'.$conn; } $db = mysql_select_db('test',$conn);//选择数据库 if(!$db){ echo '
'; die('error:'.mysql_error()); }else{ echo '
'; echo '链接数据库:'.$db; } /* mysql_query() 仅对 SELECT,SHOW,EXPLAIN 或 DESCRIBE 语句返回一个资源标识符,如果查询执行不正确则返回 FALSE。 对于其它类型的 SQL 语句,mysql_query() 在执行成功时返回 TRUE,出错时返回 FALSE。 非 FALSE 的返回值意味着查询是合法的并能够被服务器执行。这并不说明任何有关影响到的或返回的行数。很有可能一条查询执行成功了但并未影响到或并未返回任何行。 */ $sql="SELECT * FROM user"; $result = mysql_query($sql,$conn);//执行一条MySQL查询,该函数自动对记录集进行读取和缓存。如需运行非缓存查询,请使用 mysql_unbuffered_query()。 echo '
'; echo '查询结果集:'.$result;//返回资源标识符 //echo '
'; //print_r(mysql_fetch_array($result,MYSQL_ASSOC));//函数从结果集中取得一行作为关联数组 //echo '
'; //print_r(mysql_fetch_array($result,MYSQL_NUM));//函数从结果集中取得一行作为数字数组 //echo '
'; //print_r(mysql_fetch_array($result));//函数从结果集中取得一行作为关联数组与数字数组,mysql_fetch_row() 函数从结果集中取得一行作为数字数组 /* mysql_fetch_array() 函数从结果集中取得一行作为关联数组,或数字数组,或二者兼有 返回根据从结果集取得的行生成的数组,如果没有更多行则返回 false。 */ echo '
'; echo '
'; while($row = mysql_fetch_array($result)){ echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo '
" . $row['FirstName'] . " | " . $row['LastName'] . " | " . $row['Age'] . " | " . $row['Hometown'] . " | " . $row['Job'] . " |
'; echo '
'; echo '关闭非持久的 MySQL 连接:'.mysql_close(); $name = array('fruits' => array('orange', 'banana', 'apple'), 'veggie' => array('carrot', 'collard','pea'));; echo '
'; print_r($name['fruits'][1]); echo '
'; echo count($name);//计算数组中的单元数目或对象中的属性个数 echo '
'; /* 符号“->”表示:调用类的函数和成员变量 */ class className{ function funName(){ echo "dggdgdgd"; } } $classOne = new className(); $classOne->funName(); echo '
'; $i=0; do{ $i++; echo "The number is " . $i . "
";
}
while ($i

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!