I am starting web design and studying it for only two months. I was given the assignment to coded in php table in the database the data from the database, it is now the code for me no one can address right or I explain it>
The code below:
& lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Frameset // N" "http://www.w3.org/TR/html4/frameset.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Document title & lt; / Title & gt; & Lt; Meta name = "description" content = "sampleMySqlQueries.php" /> & Lt; Meta name = "keyword" content = "type, keyword, here" /> & Lt; Meta name = "author" content = "your name" /> & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Link rel = "stylesheet" type = "text / css" href = "mystyle.css" /> & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php // --- Direct variable $ servername = "localhost"; $ Username = "root"; $ Password = ""; $ Dbname = "myhighschool"; // --- Read form arguments --- --- Main code ---------------------------------- - -------------------------- // ReadRecords1 (); // InsertRecords2 (); ReadAllData (); // ------------------------------------------------ --------------------------- // Function S ------------------ - ------------------------------------------------- - ------ // --- This function receives data from a MySQL database function ReadAllData () {global $ servername, $ username, $ password, $ dbname; // Connect to database $ conn = mysqli_connect ($ servername, $ username, $ password, $ dbname); If (! $ Conn) {dead ("Connection failure:". Mysqli_connect_error ()); } // create SQL statements and database JOIN tEnrollments by $ sql are claSubject, claID on = send "the (tStudents interiors include tStudents.stuID = tEnrollments.enrStudentID Insider on tEnrollments.enrClassID = tClasses.claID order tClasses * of select, stuLastName, stuFirstName "; $ result = mysqli_query ($ con, $ sql); // loop record (recordset) if the resulting & the (mysqli_num_rows ($ result) through the set gt; 0) {// each While data in line production ($ line = mysqli_fetch_assoc ($ result)) {echo "square ID:" $ line ["claID"] "- Description:" ... $ row [ "claSubject"] "- are:" .. $ row [ "claRoomID"]. "& Lt; br & gt;";}} else {echo "0 results"; }} // --- this function inserts records in a MySQL database function InsertRecords () {global $ servername, $ username, connect to $ password, $ Dbname; // database $ conn = mysqli_connect ($ servername, $ Username, $ password, $ dbname); if (! $ Conn) {dead ("connection failed:" mysqli_connect_error ()); } // "( '201409', 'Humanity', '304') to prepare the SQL statement into the tClasses (claID, claSubject, claRoomID) values" and send it to the database $ sql =; If (mysqli_query ($ conn, $ sql)) {echo "new record successfully created"; } Else {echo "error:" $ sql "& lt; br & gt; . Mysqli_error ($ Conn); }} $ I = 0; $ C = ""; While (#row = mysqli_fetch_assoc ($ result)) {if ($ line ["claSubject"} = $ c!) {Echo "& lt; tr-> \ n & lt; td style = \" width: 200px; Background color: # 00CCFF; \ "& Gt;" . $ Line ["clad"] "& Lt; / td>"; Echo "& lt; td style = \" background-color: # 00CCFF; \ "& Gt;" . $ Line ["classbusic"]. "& Lt; / td> \ n"; Echo "& lt; td style = \" width: 200px; Background color: # 00CCFF; \ "& Gt; & amp; nn;"; } $ I ++; $ Color = "# CCFFFF"; If ($ i / 2 == interval ($ i / 2)) {// --- This function updates records in a MySQL database function UpdateRecords () {} // --- This function is a MySQL database function Deletes data removes records () {}? & Gt; & Lt; / Body & gt; & Lt; / Html & gt;
No comments:
Post a Comment