Simple example of PHPMySql addition, deletion, modification and query, phpmysql addition and deletion example_PHP tutorial
A simple example of PHP MySql addition, deletion, modification and query, phpmysql addition and deletion example mysql_connect() connects to the database mysql_select_db select database mysql_fetch_assoc() gets the result set mysql_query() executes sql statement Examples are as follows: <?php $con=@mysql_connect('localhost','root','root');//Connect to the database mysql_select_db('test',$con);//Select database $userInfo=mysql_query("select * from user",$con);//Create sql statement echo "”; while($row=mysql_fetch_assoc($userInfo))//Get the data of each row of the result set { echo “”; echo “”; echo $row[‘id’];//Get the id in the row echo “”; echo “”; echo $row[‘username’]; echo “”; echo “”; echo $row[‘password’]; echo “”; echo “”; } echo “”; mysql_free_result($userInfo);//Release the result set mysql_close($con); //Close the database /*delete $d=@mysql_connect(‘localhost’,’root’,’root’); mysql_select_db(‘test’,$d); mysql_query(“delete from user where id=1”,$d); mysql_close($d); */ /*insert $i=@mysql_connect(‘localhost’,’root’,’root’); mysql_select_db(‘test’,$i); mysql_query(“insert into user(username,password) values(‘ad’,’ad’)”,$i); mysql_close($i); */ //update $u=@mysql_connect(‘localhost’,’root’,’root’); mysql_select_db(‘test’,$u); mysql_query(“update user set username=’aaa’ where username=’00′”,$u); echo “update user set username=’ax’ where id=2”; mysql_close($u); ?> The above simple example of PHP MySql addition, deletion, modification and query is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia. http://www.bkjia.com/PHPjc/1136618.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1136618.htmlTechArticlePHP MySql addition, deletion, modification and query simple example, phpmysql addition and deletion example mysql_connect() connects to the database mysql_select_db selects the database mysql_fetch_assoc() gets…
php+mysql object-oriented addition, deletion, modification and query
I’m a newbie, looking for guidance. localhost = $localhost; //use $this->localhost instead. $this->root = $root; $this->password = $password; $this->database = $database; } public function Connect(){ mysql_connect ($this->localhost,$this-root,$this- >password); mysql_select_db ($this->database); mysql_query (“set names utf8”); } public function Close(){ mysql_close(); } public function myarray($result){ //Formal parameters return mysql_fetch_array($ result); } public function myquery($sql){ return @mysql_query($sql); } public function myrows($result){ return mysql_num_rows($result); } public function myselect($users){ return $this-> myquery(“select * from $users”); }}$db = new Mysql(“localhost”,”root”,””,”stu_system”); id name sex phone myselect(“users”); if(is_array($result)){ while($row=$db ->myarray($result)){?> & name = & sex = & phOne= “> Modify “> Delete Can’t get mine Resources, can’t find the problem. Reply to discussion (solution) if(is_array($result)){ This sentence There is a problem with judgment. $result should be resource, not array You can var_dump(is_array($result)); is boolean false. Change to: if($db->myrows($result)>0){ The Connect method is not executed The myquery method is not executed The myselect method returns resources The Connect method is not executed The myquery method is not executed The myselect method returns resources Same as above localhost = $localhost; //Replace with $this->localhost. $this->root = $root; $this->password = $password; $this->database = $database; } public function Connect(){ $this->link = mysql_connect($this->localhost, $this ->root, $this->password); mysql_select_db ($this->database, $this->link ); mysql_query (“set names utf8”);…
PHP addition, deletion, modification and query
php Write your review! Come on, watch it all Member login | User registration Recommended reading php 32. Introduction of microservice gateway 32. Introduction of microservice gateway… [detailed] Crayon Shin-chan 2023-09-11 12:50:15 php java – How to allow anonymous login in org.apache.ftpserver? I wrote some code like this to start the ftp server embedded in my application. It is based on apacheftpserver and I found that anonymous users cannot log in. The client keeps 530. Have I added the configuration for ftp… [detailed] Crayon Shin-chan 2023-09-11 12:49:22
PHP simple addition, deletion, modification and query
dbconn.php <?php // Create database connection $con = mysql_connect(“localhost”,’root’,”) or die (‘error:’.mysql_error()); mysql_select_db(‘hyxx’,$con) or die(‘error:’.mysql_error()); mysql_query(‘ set NAMES utf8’); ?> adduser.php Username Password Gender MaleFemale Age Year and month of birth 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 Year 1 2 3 4 5 6 7 8 9 10 11 12 month 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Day Hobbies Personal profile adddo.php <?php require_once ‘inc/dbConn.php’; // /////////////////// >10 <option value="11" >11 <option value="12" > 12 <option value="13" >13 <option value="14" >14 <option value="15" >15 <option value="16 " >16 <option value="17" >17 <option value="18" >18 <option value="19" >19 <option value="20" >20 <option value="21" >21 <option value="22" >22 <option value="23" >23 <option value= "24" >24 <option value="25" >25 <option value="26" >26 <option value="27" >27 <option value="28" >28 <option value="29" >29 <option value="30" >30 <option value="31" >31 Day Hobby <input type="text" name="hobby" size="44" value= / > Personal profile editdo.php <?php require_once ‘inc/dbConn.php’; ////////////////// /// ///Get user information ///////////////////// $user_id = $_POST[‘user_id’]; $user_name = $_POST[‘user_name’]; $password= $_POST[‘password’]; if($_POST[‘sex’]==’male’) { $sex=1; } else if($_POST[‘sex’]==’female’) {…
ThinkPHP learning notes (8) A small example of user addition, deletion, modification and query
ThinkPHP study notes (8) A small example of user addition, deletion, modification and query Mainly the implementation of the action file method: conf file ‘Configuration value’ //Because the URL is opened again, whether it is rewritten or not rewritten, it can be accessed through the original path. //If you want to enable rewrite mode, you need to do the following operations //1.query server has enabled Apache’s rewrite module // LoadModule rewrite_module modules/mod_rewrite.so //2. Create a new .htaccess (vi:save .htaccess; Notepad: “.htaccess”) in the main entry file and statistics directory. //If you choose mode 2 (rewrite), it will increase server consumption. ‘URL_MODEL’=>1, ‘URL_PATNINFO_MODEL’=>2, //pathinfo contains two categories //1 Normal mode: Add m and a: the order relationship can change //http://localhost/MyThinkPHP/admin.php/m/index/a/index //pass value //http://localhost/MyThinkPHP/admin.php/m/index/a/index/username/zhangsan/password/password //2 Intelligent identification module operation (the default mode is intelligent identification) //http://localhost/MyThinkPHP/admin.php/index/index //pass value //http://localhost/MyThinkPHP/admin.php/index/index/username/zhangsan/password/password //Modify URL separator //’URL_PATHINFO_DEPR’=>’-‘, //Modify the left and right delimiters of the template ‘TMPL_L_DELIM’=>”, //******************************Very gorgeous dividing line****************** *************************** //Enable debug mode //1. Simulate linux system to identify upper and lower case //2. The case of the method name is related to the case of the template file. //Note: In the framed page, there cannot be a body, but the information of app_dubug…
How to make php operate mysql_php how to operate mysql addition, deletion, modification and query
How to add, delete, modify and query mysql in php Release time :2020-07-14 16:20:21 Source : Yisuyun Read :99 Author :Leah How does php operate the addition, deletion, modification and query of mysql ?Many novices are not very familiar with this Clearly & # xff0c; In order to help you solve this problem & # xff0c; the following editor will explain in detail & # xff0c; those who have this need can come to learn & # xff0c; I hope you can gain something. Add, delete, modify and query method of php operating mysql : 1. Insert statement [insert into data table name (field 1, field 2,….) values(“value 1”, “value 2”,..)] ;2. Delete statement [delete from indicates where field & # 61; & # 39; condition & # 39; ]. How to add, delete, modify and query php to operate mysql : 1, the first step : go to the www folder directory in wamp , create a test folder , and then create a message folder in the test folder , to store each file that is added, deleted, modified, and checked. (Specific picture) 2. The second step : remember to open wamp, and then create a conn. The…
PHP summary (5) Database connection addition, deletion, modification and query
1. Database successfully connected $dbhost = ‘localhost’; // mysql server host address $dbuser = ‘root’; // mysql username $dbpass = ‘123456’; // mysql username and password $a = mysqli_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die(‘Could not connect: ‘ . mysqli_error()); } echo ‘The database connection is successful! ‘; mysqli_close($a); PDO method query($sql); $arr=$smt->fetchAll(pdo::FETCH_ASSOC); foreach ($arr as $arrs) { echo ”; echo “{$arrs[‘id’]} “; echo “{$arrs[‘name’]}”; echo “{$arrs[‘sex’] }”; echo ” {$arrs[‘shouji’]} “; echo “”; } ?> 2. Query database // Activate the database$s= mysql_select_db(‘myapp’,$a); // Execute a query, search range such as SELECT id, name FROM users WHERE age=11; $r= mysql_query(“SELECT * FROM users”); // Display query data in array form $aar=mysql_fetch_array($r); // get the number of data $num=mysql_num_rows($r); for loop display content // for ($i=0; $i <$num; $i++) { // $aar=mysql_fetch_assoc($r); // print_r($aar); // } // Statement 1: select count(*) from T; // Function: Query the number of rows recorded in the T table. // Statement 2: select * from T; // Role: Query all records in the T table $an=mysql_query(“SELECT COUNT(*) FROM users “); $anarr=mysql_fetch_array($an); print_r ($anarr) ; echo “$anarr[0]”; 3. Database insertion 1. First connect to the database 2. config.php set public php $cOnn=@mysql_connect(‘localhost’,’root’,’Aa1223425′,’myapp’); if (!$conn)…
A simple example of PHPMySql addition, deletion, modification and query, phpmysql addition and deletion example_PHP Tutorial
Simple example of PHP MySql addition, deletion, modification and query, phpmysql addition and deletion example mysql_connect() to connect to the database mysql_select_db select database mysql_fetch_assoc() to get the result set mysql_query() executes sql statement Examples are as follows: <?php $con=@mysql_connect('localhost','root','root');//Connect to the database mysql_select_db('test', $con);//select database $userInfo=mysql_query("select * from user", $con);//create sql statement echo " “; while($row=mysql_fetch_assoc($userInfo))//Get the data of each row of the result set { echo “ “; echo “ “; echo $row[‘id’];//Get the id in the row echo “ “; echo “ “; echo $row[‘username’]; echo “ “; echo “ “; echo $row[‘password’]; echo “ “; echo “ “; } echo “ “; mysql_free_result($userInfo);//Release the result set mysql_close($con); //Close the database /*delete $d=@mysql_connect(‘localhost’,’root’,’root’); mysql_select_db(‘test’, $d); mysql_query(“delete from user where id=1”, $d); mysql_close($d); */ /*insert $i=@mysql_connect(‘localhost’,’root’,’root’); mysql_select_db(‘test’, $i); mysql_query(“insert into user(username,password) values(‘ad’,’ad’)”,$i); mysql_close($i); */ //update $u=@mysql_connect(‘localhost’,’root’,’root’); mysql_select_db(‘test’, $u); mysql_query(“update user set username=’aaa’ where username=’00′”, $u); echo “update user set username=’ax’ where id=2”; mysql_close($u); ?> The above simple example of adding, deleting, modifying and checking PHP MySql is all the content shared by the editor. http://www.bkjia.com/PHPjc/1136618.htmlwww. bkjia.comtruehttp://www.bkjia.com/PHPjc/ 1136618.htmlTechArticleSimple example of PHP MySql addition, deletion, modification and query, phpmysql addition and deletion example mysql_connect() to connect to the database mysql_select_db…
php+mysql object-oriented addition, deletion, modification and query, how to solve it
Back-end development | php tutorial nbsp,gt,lt,mysql,localhost back-end development-php tutorial php+mysql object-oriented addition, deletion, modification and queryA novice, please guide . Dream weaving video station source code download, ubuntu and Kirin, start two tomcat locally, online crawler music, php confirm password and input password, Handan seo lecturer lzw <?php// Mysql_class.php class Mysql{ private $localhost; private $root; private $password; public $database; public function __construct($localhost,$root,$password,$database) { //In the following methods, if you want to use the $localhost variable $this->localhost = $localhost; //Use $this->localhost instead. $this->root = $root; $this->password = $password; $this->database = $database; } public function Connect( ){ mysql_connect ($this->localhost,$this-root,$this->password); mysql_select_db ($this->database); mysql_query (“set names utf8”); } public function Close(){ mysql_close(); } public function myarray($result){ //formal parameter return mysql_fetch_array($result); } public function myquery($sql){ return @mysql_query($sql); } public function myrows( $result){ return mysql_num_rows($result); } public function myselect($users){ return $this->myquery(“select * from $ users”); }}$db = new Mysql(“localhost”,”root”,””,”stu_system”); id name sex phone <?php include_once “mysql_class.php”; $result = $db->myselect(“users”); if(is_array($result)){ while($row=$db->myarray($result)){?> & name = & sex = & phOne=”> Modify “> Delete <?php } } else echo “no result”; mysql_close();?> I can’t get my resources, and I can’t find the problem. ——Solution ideas——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— Internet, sqlite is too slow, corporate web design costs, asp update access database,…