私には、「プラント」テーマを持つデータベースがあります。私は、バラ植物の詳細を検索してその値をフィールドに配置するスクリプトを必要としています。その後、ユーザーが項目を更新してデータベースに戻してもらう機能が必要です。フォームでSELECTおよびUPDATEクエリを使用します。
「rose」テーブルの一意の属性であるラテンの名前で、データベースからアイテムをプルする必要があります。ここでバラを挿入するためのコードがあり、誰かが私は、私はそれがプリペアドステートメントを使用してくださいする方法にこれを適応させる助けてくださいことができます:
//connect to database
$conn2 = DB2();
require_once('header_admin.php');
/*
if (isset($_POST['addrose']))
{
//detect if we have errors or not
$errors = false;
$error_msg = "Error, please try again";
/*
* Could do other validation here
* Make sure they enter an email address for example
*/
//if we have no errors, do the SQL
if (!$errors) {
$latin_name = $_POST['latin_name'];
$common_name = $_POST['common_name'];
$variety_name = $_POST['variety_name'];
$colour = $_POST['colour'];
$season = $_POST['season'];
$hardiness = $_POST['hardiness'];
$situation = $_POST['situation'];
$soil_type = $_POST['soil_type'];
$price = $_POST['price'];
$fragrance = $_POST['fragrance'];
$height = $_POST['height'];
//insert data
$stmt = $conn2->prepare("INSERT INTO rosename (latin_name, common_name, variety_name, colour, season_of_interest, hardiness, situation, soil_type, price,
fragrance, ultimate_height) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
//bind the parameters
$stmt->bind_param('ssssssssdss', $latin_name, $common_name, $variety_name, $colour, $season, $hardiness, $situation, $soil_type, $price, $fragrance,
$height);
// Execute query
$stmt->execute();
//if the query worked, put out the confirmation message (you can make this look however you want)
if ($stmt) {
echo "<p class='black'>Rose Added!</p>";
なぜフレームワークを使用しないのですか? – Teson