2
나는 그림을 포함하여 하나의 레서피를 생성해야하는 안드로이드 앱을 만들고 있습니다. 나는 하나의 PHP 파일 create_recipe.php
, 그 파일에 내가 제목, 재료, 설명 및 카테고리를 만드는거야 -이 모든 값은 단일 쿼리에서 생성됩니다. 또한 UploadImage.php
이라는 두 번째 PHP 파일이있어 갤러리 또는 카메라에서 사진을 선택하고 웹 서버에 업로드하면 단일 쿼리에서도이 작업을 수행 할 수 있습니다. 내 Java 코드에서 먼저 create_recipe.php
을 호출하고 나서 UploadImage.php
을 호출합니다. 이렇게하면 다른 행에 정보가 저장됩니다.2 개의 PHP 파일에서 2 개의 쿼리 추가하기
DB의 단일 행에서이 쿼리를 만들 수있는 방법이 있습니까? 어떤 도움이라도 대단히 감사하겠습니다!
여기 여기 create_recipe.php
<?php
/*
* Following code will create a new recipe row
* All recipe details are read from HTTP Post Request
*/
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['title'])
&& isset($_POST['ingredients'])
&& isset($_POST['description'])
&& isset($_POST['category'])) {
// && isset($_POST['image'])
$title = $_POST['title'];
$ingredients = $_POST['ingredients'];
$description = $_POST['description'];
$category = $_POST['category'];
// include db connect class
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/android_connect/db_connect.php');
// connecting to db
$db = new DB_CONNECT();
// mysql inserting a new row
$result = mysql_query("INSERT INTO scb(title, ingredients, description, category, name) VALUES('$title', '$ingredients', '$description', '$category', '$target_path')");
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Recipe successfully created.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}