Home > Backend Development > PHP Tutorial > PHP daodb insert, update and delete data_PHP tutorial

PHP daodb insert, update and delete data_PHP tutorial

WBOY
Release: 2016-07-21 15:46:58
Original
864 people have browsed it

Copy code The code is as follows:

include("adodb/adodb.inc.php"); /Contains adodb class library file
$conn = NewADOConnection('mysql'); //Connect to the database
$conn -> Connect('localhost', 'root', '1981427', 'test');
$conn -> Execute("insert into tablename1 values('9','zhuzhao', 'Simon')"); //Execute SQL
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); /Contains adodb class library file
$conn = NewADOConnection('mysql'); //Create adodb object and declare the database type to be MySQL
$conn->Connect("localhost", "root", "1981427 ", "test"); //Connect to the database, where mydb is the database name
$sqle = $conn->Execute("insert into tablename1 values('10','zhuzhao','Simon')") ; //Use $sqle to determine whether SQL execution is successful
if($sqle) //If execution is successful, output successful execution information
{
echo "SQL execution is successful";
}
else //If execution fails, output error message
{
echo $conn->ErrorMsg();
}
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); /Contains adodb class library file
$conn = NewADOConnection('mysql'); //Create adodb object and declare the database type to be MySQL
$conn->Connect("localhost", "root", "1981427 ", "test"); //Connect to the database, where mydb is the database name
$rs = $conn->Execute("SELECT * FROM tablename1"); //Execute the SQL statement and save the results in the result set
if($rs) //If the execution is successful, output information about the successful execution of the statement
{
echo "The statement is executed successfully";
}
else //If the execution fails, then Output error message
{
echo $conn->ErrorMsg();
}
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn = NewADOConnection('mysql'); //Create an adodb object and declare the database type to be MySQL
$conn->Connect("localhost", "root", "1981427", "test"); //Connect to the database , where mydb is the database name
$rs = $conn->Execute("SELECT * FROM tablename1"); //Execute the SQL statement and save the results in the result set
if($rs) //If If the execution is successful, then loop to read the result set
{
while (!$rs->EOF) //Loop to read all records in $rs
{
echo $rs-> fields[0].' '.$rs->fields[1].' '.$rs->fields[2].'
'; //Output the current line
$rs-> ;MoveNext(); //Move the pointer to the next record
}
}
else //If the execution fails, output an error message
{
echo $conn->ErrorMsg ();
}
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn = NewADOConnection('mysql'); //Create adodb object and declare database type For MySQL
$conn->Connect("localhost", "root", "1981427", "test"); //Connect to the database, where mydb is the database name
$rs = $conn-> Execute("SELECT * FROM tablename1"); //Execute the SQL statement and save the results in the result set
if($rs) //If the execution is successful, loop to read the result set
{
while (!$rs->EOF) //Loop to read all records in $rs
{
echo $rs->fields['id'].' '.$rs->fields[ 'username'].' '.$rs->fields['password'].'
'; //Output the current line
$rs->MoveNext(); //Move the pointer to Next record
}
}
else //If execution fails, output error message
{
echo $conn->ErrorMsg();
}
? >

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320050.htmlTechArticleCopy the code as follows: ?php include("adodb/adodb.inc.php"); //Include adodb Class library file $conn = NewADOConnection('mysql'); //Connect to the database $conn - Connect('localhost', 'root',...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template