私は何をしているのか分かりません。別のクエリに基づいてデータベースから変数を取得する
私のコードでは、ネストされたカテゴリのCSVリストを取得します。私は各csv行に親カテゴリの名前を追加したいと思います。
私はcategory_descriptionテーブルに別の検索を行うと、私はコメントしている私は 前だPARENT_IDにCATEGORY_IDに一致するカテゴリ名を見つけたいカテゴリ名、category_parent_id、category_imageので
上を取得しています場合と同様私は
<?php
DEFINE ('DBUSER', 'myosjrjp_osco638');
DEFINE ('DBPW', 'plS]q4)U78');
DEFINE ('DBHOST', 'localhost');
DEFINE ('DBNAME', 'myosjrjp_osco638');
error_reporting(E_ALL | E_ALL);
$dbc = mysqli_connect(DBHOST,DBUSER,DBPW);
if (!$dbc) {
die("Database connection failed: " . mysqli_error($dbc));
exit();
}
$dbs = mysqli_select_db($dbc, DBNAME);
if (!$dbs) {
die("Database selection failed: " . mysqli_error($dbc));
exit();
}
$result = mysqli_query($dbc, "SHOW COLUMNS FROM categories");
$numberOfRows = mysqli_num_rows($result);
if ($numberOfRows > 0) {
/* By changing Fred below to another specific persons name you can limit access to just the part of the database for that individual. You could eliminate WHERE recorder_id='Fred' all together if you want to give full access to everyone. */
$values = mysqli_query($dbc, "SELECT categories.categories_id, categories.categories_image, categories.parent_id, categories_description.categories_id, categories_description.language_id, categories_description.categories_name, categories_description.categories_description
FROM categories
JOIN categories_description
WHERE categories.categories_id = categories_description.categories_id ");
while ($rowr = mysqli_fetch_row($values)) {
for ($j=0;$j<$numberOfRows;$j++) {
\t /////////
// \t $parent= mysqli_fetch_row($values,'categories.parent_id');
// \t $values2 = mysqli_query($dbc, "SELECT categories_name,
//FROM categories_description
//WHERE categories_id = '$parent'");
\t //////
$csv_output .= $rowr[$j].", ";
// $csv_output .= $values2('categories_name').", ";
}
$csv_output .= "\n";
}
}
print $csv_output;
exit;
?>
* "私は何をしているのか分かりません" * - これは本当に質問が本当に何であるかをわかりやすくします。ここで働いていないのは何ですか? –
と以前のあなたの他の質問に関連しているようですhttp://stackoverflow.com/q/40289135/ - 再投稿しないでください。追加された情報であなたの他の質問を編集してください。 –