ฉันกำลังพยายามสร้างหน้าแก้ไขที่อ่านข้อมูลจาก MySQL ด้วย PHP แล้วแสดงในรูปแบบ HTML\nฟิลด์ปกติ เช่น VARCHAR แสดงได้อย่างถูกต้อง แต่ฉันประสบปัญหาในการแสดงฟิลด์ TEXT
\n<?php\n $DATABASE_HOST = \'\';\n $DATABASE_USER = \'\';\n $DATABASE_PASS = \'\';\n $DATABASE_NAME = \'\';\n \n mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);\n $mysqli = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);\n if ( mysqli_connect_errno() ) {\n exit(\'Failed to connect to MySQL: \' . mysqli_connect_error());\n }\n \n $idjob = $_POST[\'jobID\']; \n $jobquery = $mysqli->prepare(\'SELECT * FROM jobs WHERE id = ?\');\n $jobquery->bind_param(\'s\', $idjob); // \'s\' specifies the variable type => \'string\'\n\n $jobquery->execute();\n\n $jobresult = $jobquery->get_result();\n while ($row = $jobresult->fetch_assoc()) {\n $jobtitle = $row[\'jobtitle\'];\n $workhours = $row[\'workhours\'];\n $type = $row[\'type\']; \n $availfrom = $row[\'availfrom\'];\n $deadline = $row[\'deadline\']; \n $customer = $row[\'customer\'];\n $province = $row[\'province\'];\n $town = $row[\'town\']; \n $minreq = $row[\'minreq\'];\n $posdetails = $row[\'posdetails\'];\n $minsal = $row[\'minsal\'];\n $maxsal = $row[\'maxsal\'];\n }\n mysqli_free_result($jobresult);\n mysqli_close($mysqli);\n\n?>\n<!DOCTYPE html>\n\n<html lang="en">\n <head>\n <title>Edit Job Listing</title>\n <link rel="shortcut icon" type="image/jpg" href="images/Logo.jpg">\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0 shrink-to-fit=no"> \n <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">\n <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> \n <link rel="stylesheet" href="../assets/css/style.css" type="text/css"/>\n </head>\n <body id="editjoblisting">\n <!-- Container (About Add New Job Listing Section) -->\n <div id="abouteditnewjob" class="container-fluid bg-grey">\n <div class="row">\n <div class="col-sm-2"></div>\n <div class="col-sm-8">\n <div class="text-center">\n <h2> Edit Job Listing </h2>\n </div>\n </div>\n <div class="col-sm-2"></div>\n </div>\n </div>\n <div class="container-fluid bg-grey">\n <form method="post" id="updedit_form" action="../php/updeditjob.php">\n <div class="form-row">\n <div class="col-sm-2"></div>\n <div class="col-sm-4">\n <div class="form-group"> \n <label for="jobtitle"> Job Title</label>\n <input type="text" class="form-control" name="jobtitle" value=\'<?php echo $jobtitle; ?>\'> \n\n <label for="workhours"> Working Hours</label> \n <input type="text" class="form-control" name="workhours" value=\'<?php echo $workhours; ?>\'> \n\n <label for="worktype">Type</label>\n <select class="form-control" name="worktype" >\n <option value=\'<?php echo $type; ?>\' selected><?php echo $type; ?></option>\n <option>--None--</option>\n <option>Temporary</option>\n <option>Permanent</option> \n </select>\n\n <label for="availfrom"> Available From</label> \n <input type="date" class="form-control" id="availfrom" name="availfrom" required maxlength="50" value=\'<?php echo $availfrom; ?>\'> \n\n <label for="deadline"> Application Deadline</label> \n <input type="date" class="form-control" id="deadline" name="deadline" required maxlength="50" value=\'<?php echo $deadline; ?>\'> \n </div>\n </div>\n <div class="col-sm-4">\n <div class="form-group">\n <label for="minreq">Minimum Requirements</label>\n <textarea class="form-control" type="textarea" name="minreq" id="minreq" maxlength="6000" rows="5" value=\'<?php echo $minreq; ?>\'></textarea>\n\n <label for="posdetails">Position Details</label>\n <textarea class="form-control" type="textarea" name="posdetails" id="posdetails" maxlength="6000" rows="5" value=\'<?php echo $posdetails; ?>\'></textarea>\n\n <label for="minsal"> Minimum Salary</label> \n <input type="text" class="form-control" id="minsal" name="minsal" value=\'<?php echo $minsal; ?>\'> \n\n <label for="maxsal"> Maximum Salary</label> \n <input type="text" class="form-control" id="maxsal" name="maxsal" value=\'<?php echo $maxsal; ?>\'> \n </div> \n </div>\n <div class="col-sm-2"></div> \n </div> \n </form>\n </div>\n </body>\n</html> \n
\nนี่คือข้อมูลที่ฉันพยายามแสดง/แก้ไข
\nid "251" \njobid "ID#20101664"\njobtitle "SENIOR CONVEYANCING SECRETARY" \nworkhours "Monday - Friday 7:00 - 17:00" \ntype "Permanent" \navailfrom "2021-06-07" \ndeadline "2021-10-29" \n\nminreq \n"- Matric Certificate\n- Minimum 3 years experience \n- Knowledge in Law programs (Lexis Nexis, Windeed) – Compulsory\n- Knowledge of Bonds: Absa, Standard Bank, FNB and Nedbank\n- Bilingual (English & Afrikaans)\n- Computer literate\n- Be accurate and methodical etc.." \\N \nminsal "0" \nmaxsal "0"\n
\nทุกอย่างทำงานได้ดียกเว้น minreq ซึ่งเป็นฟิลด์ TEXT ใน MySQL ไม่แสดง แต่เสียงสะท้อนแสดงว่าได้รับในอาร์เรย์ $row แล้ว
\nลองสะท้อนค่าระหว่างแท็ก textarea ไม่ใช่ในแอตทริบิวต์ของค่า:
\n<textarea class="form-control" type="textarea" name="minreq" id="minreq" maxlength="6000" rows="5"><?php echo $minreq; ?></textarea>\n รหัส>
\n โปรดลบค่าออกจากพื้นที่ข้อความและเขียนโค้ดดังนี้:
\n//here is the valid code...this will 100% work.\n<textarea class="form-control" type="textarea" name="posdetails" id="posdetails" maxlength="6000" rows="5">\n <?php echo $posdetails; ?>\n</textarea>\n รหัส>
\n Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL.
It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/
CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language.
It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.
https://www.w3.org/TR/CSS/#css
Bootstrap is not exclusively a CSS framework, but its most popular features are CSS-centric. These include a powerful grid, icons, buttons, map components, navigation bars, and more.
https://getbootstrap.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.