Used in SQL table
CREATE TABLE `student_01` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名字', `kecheng` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `score` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `other_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, KEY `aaaa` (`other_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
The data processing of input variables
// input variable data processing // input variables as follows: // 01) preparation (resolve) the statement 02) bind variables 03) assigned to the bind variable 04) execute a prepared statement $ conn = mysqli_connect ( '127.0.0.1 ',' afei2 ',' 123456 ',' Test '); $ conn-> Query ( "SET names utf8mb4"); $ stmt = $ conn-> PREPARE ( "the INSERT the INTO student_01 (name, kecheng, Score, other_id) VALUES ") (,,,????); $ stmt-> bind_param ( 'SSDI', $ name, $ kecheng, $ Score, $ other_id); // The first parameter is the specified type $ name = 'big fly '; $ kecheng =' math '; $ Score = 75; $ other_id = 1; $ stmt-> the Execute (); $ name =' big fly 02 '; $ kecheng =' language '; $ Score = 60; $ =. 1 other_id; $ stmt-> Execute (); $ stmt-> Close ();
Examples of bind variables acquired
Examples // bind variables obtained // output variables as follows: // 01) preparation (analytical) statement 02) execute a prepared statement 03) Binding output variable 04) to extract the data to the output variable $ conn = mysqli_connect ( '127.0.0.1', 'afei2', '123456', 'Test'); $ conn-> Query ( "SET names utf8mb4"); $ stmt = $ conn-> PREPARE ( "the SELECT ID, name, kecheng, Score student_01 the FROM "); $ stmt-> bind_result ($ ID, name $, $ kecheng, $ Score); // variables defined herein $ stmt-> Execute (); Print" <Table border = '. 1'>. " PHP_EOL; Print "<TR> <TH> ID </ th> <th> name </ th> <th> course </ th> <th> fraction </ TH> </ TR>" PHP_EOL;. the while ($ stmt-> FETCH ()) { Print "<TR> <TD> $ ID </ TD> <TD> name $ </ TD> <TD> $ kecheng </td><td>$score</td></tr>" . PHP_EOL; } print "</table>" . PHP_EOL; $stmt->close();