1. Common methods for linking databases: conn.php<?PHP//First step: Link database [email protected]_connect ("localhost:3306", "root", "root") or Die ("MySQL link failed");//Second step: Select the specified database, Sets the character set @mysql_select_db ("Php_blog", $conn) or Die ("DB link Failed". mysql_error ()); mysql_query (' Set NAMES UTF8 ') or Die ("CharSet set Error"); ?>2. Query Judgment select.php<?php include ("conn.php"),//Introduce the link database <pre name= "code" class= "HTML" ><?php include ("conn.php");//introduce the linked database if ( !empty ($_get[' id ')) {$sql = "SELECT * from news where id= '". $_get[' id ']. "'"; $query =mysql_query ($sql); $rs =mysql_fetch_ Array ($query); Determine if the $RS has a value indicating that the database exists, otherwise the database does not exist;}?> <formAction= "add.php"Method= "POST">Title:<inputtype= "text"name= "title"><BR>content:<textarearows= "5"cols= " the"name= "Con"></textarea><BR> <inputtype= "Submit"name= "Sub"value= "POST"> </form>
Database query Form Values