<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >Echo' Hello world! ' ;</script><?Echo' Hello world! '; ><%Echo' Hello world! '; %><?PHPEcho"Hello world!";//single-line comment Echo"<p>" ; /*Multi-line comments*/ #shell script Style comments $boo=true ; if($boo==true) { Echo' Variable $boo is true '. <br> " ; } $str= ' String ' ; Echo"$str" ; Echo' $str '. " <br> " ; $arr=Array(' A1 ', ' A2 ', ' A3 ') ; Echo"Current file path:".__file__." <br> ";//pre-defined constants $str 1=$str;//assigning values, using their own memory $str 2= &$str 1 //reference Assignment (equivalent to another name)? ><?PHPfunctionFUN1 ($sum)//Defining Functions { return"$sum*$sum= ".$sum*$sum ; } EchoFUN1 (10). " <br> " ; $con=mysql_connect("localhost", "root", "Newman");//connect to MySQL database if(!$con) { die(' Could not connect: '.Mysql_error()); }/*if (mysql_query ("CREATE Database my_db", $con)) {//CREATE DATABASE echo "DB created"; } else {echo "Error Creating Database:". Mysql_error (); }*/ mysql_select_db("my_db",$con);//Select a database/*$sql = "CREATE TABLE Persons (personID int not NULL auto_increment, PRIMARY KEY (PersonID), FirstName varchar (LastName), varchar (+), age int) ";*//*mysql_query ("INSERT into Persons (FirstName, LastName, age) VALUES (' Peter ', ' Griffin ', ' 35 ')"); mysql_query ("INSERT into Persons (FirstName, LastName, age) VALUES (' Glenn ', ' quagmire ', '") ");*/ $result=mysql_query("SELECT * from Persons WHERE firstname= ' Peter '"); //$result = mysql_query ("select * from Persons ORDER by age"); mysql_query("UPDATE Persons SET age = ' ' WHERE FirstName = ' Peter ' and LastName = ' Griffin '"); //mysql_query ("DELETE from Persons WHERE lastname= ' Griffin '"); while($row=Mysql_fetch_array($result)) { Echo $row[' FirstName ']. " " .$row[' LastName '] . " " .$row[' Age ']; Echo"<br/>"; } Mysql_close($con);?></body>
For the first time, you need to run the CREATE database and database table in the comment, and comment out the Add record code to the database table to avoid adding it multiple times.
Getting Started with PHP