Php 之前你能帮我举个例子吗?但是。。。它仍在进行2次查询,我只需要1次:(亲爱的Jo Libertire,是的,我们可以进行一次查询,但如果您的数据库表包含大量数据,则可能会降低数据库性能。我为此添加了一个新的解决方案,请您检查一次。但是……它仍在进行2次查询
Php 之前你能帮我举个例子吗?但是。。。它仍在进行2次查询,我只需要1次:(亲爱的Jo Libertire,是的,我们可以进行一次查询,但如果您的数据库表包含大量数据,则可能会降低数据库性能。我为此添加了一个新的解决方案,请您检查一次。但是……它仍在进行2次查询,php,mysql,sql,Php,Mysql,Sql,之前你能帮我举个例子吗?但是。。。它仍在进行2次查询,我只需要1次:(亲爱的Jo Libertire,是的,我们可以进行一次查询,但如果您的数据库表包含大量数据,则可能会降低数据库性能。我为此添加了一个新的解决方案,请您检查一次。但是……它仍在进行2次查询,我只需要1次:(亲爱的Jo Libertire,是的,我们可以使用一个查询,但如果您的数据库表包含大量数据,则可能会降低数据库性能。我已为此添加了一个新的解决方案,请您检查一次。 // query PARENT tags with this
之前你能帮我举个例子吗?但是。。。它仍在进行2次查询,我只需要1次:(亲爱的Jo Libertire,是的,我们可以进行一次查询,但如果您的数据库表包含大量数据,则可能会降低数据库性能。我为此添加了一个新的解决方案,请您检查一次。但是……它仍在进行2次查询,我只需要1次:(亲爱的Jo Libertire,是的,我们可以使用一个查询,但如果您的数据库表包含大量数据,则可能会降低数据库性能。我已为此添加了一个新的解决方案,请您检查一次。
// query PARENT tags with this Design ID
$list_tags_link_query = "SELECT * FROM shop_tags_link JOIN shop_tags ON shop_tags_link.tag_id = shop_tags.tag_id WHERE shop_tags_link.design = '$design'";
$list_tags_link_exec = mysql_query($list_tags_link_query) or die(mysql_error());
while($row = mysql_fetch_array($list_tags_link_exec)) {
$tag_id = $row["tag_id"];
$tag_fr = utf8_decode($row["tag_fr"]);
$tag_en = utf8_decode($row["tag_en"]);
echo "[<a href=\"$canon/?delete=$tag_id\">x</a>] $tag_fr ($tag_en), ";
// query CHILD tags with the corresponding PARENT's tag_id
$list_tags_child_query = "SELECT * FROM shop_tags WHERE parent_tag_id = '$tag_id'";
$list_tags_child_exec = mysql_query($list_tags_child_query) or die(mysql_error());
while($row = mysql_fetch_array($list_tags_child_exec)) {
$tag_fr = utf8_decode($row["tag_fr"]);
$tag_en = utf8_decode($row["tag_en"]);
$tag_id = $row["tag_id"];
echo "<font size=\"1\">[<a href=\"$canon/?delete=$tag_id\">x</a>] $tag_fr ($tag_en), </font>";
}
}
// query PARENT tags with this Design ID
$list_tags_link_query = "SELECT * FROM shop_tags_link JOIN shop_tags ON shop_tags_link.tag_id = shop_tags.tag_id WHERE shop_tags_link.design = '$design'";
$list_tags_link_exec = mysql_query($list_tags_link_query) or die(mysql_error());
while($row = mysql_fetch_array($list_tags_link_exec)) {
$tag_id = $row["tag_id"];
$tag_fr = utf8_decode($row["tag_fr"]);
$tag_en = utf8_decode($row["tag_en"]);
echo "[<a href=\"$canon/?delete=$tag_id\">x</a>] $tag_fr ($tag_en), ";
// query CHILD tags with the corresponding PARENT's tag_id
$list_tags_child_query = "SELECT * FROM shop_tags WHERE parent_tag_id = '$tag_id'";
$list_tags_child_exec = mysql_query($list_tags_child_query) or die(mysql_error());
while($child_row = mysql_fetch_array($list_tags_child_exec)) {
$tag_fr = utf8_decode($child_row["tag_fr"]);
$tag_en = utf8_decode($child_row["tag_en"]);
$tag_id = $child_row["tag_id"];
echo "<font size=\"1\">[<a href=\"$canon/?delete=$tag_id\">x</a>] $tag_fr ($tag_en), </font>";
}
}
$list_tags_link_query = "SELECT stl.*,st.*,(select GROUP_CONCAT(CONCAT_WS('@@',in_t.tag_id,if(in_t.tag_fr <> '',in_t.tag_fr,''),if(in_t.tag_en <> '',in_t.tag_en,'')) SEPARATOR '|||') from shop_tags as in_t where in_t.parent_tag_id = stl.tag_id) as childs_details FROM shop_tags_link stl JOIN shop_tags st ON stl.tag_id = st.tag_id WHERE stl.design = '$design'";
$list_tags_link_exec = mysql_query($list_tags_link_query) or die(mysql_error());
while ($row = mysql_fetch_array($list_tags_link_exec)) {
$tag_id = $row["tag_id"];
$tag_fr = utf8_decode($row["tag_fr"]);
$tag_en = utf8_decode($row["tag_en"]);
echo "[<a href=\"$canon/?delete=$tag_id\">x</a>] $tag_fr ($tag_en), ";
$childs_details=$row["childs_details"];
if($childs_details!=""){
$child_row=explode("|||",$childs_details);
if(is_array($child_row) && count($child_row)>0){
for($i=0;$i<count($child_row);$i++){
$child_row_detail=explode("@@",$child_row[$i]);
$tag_id = $child_row_detail[0];
$tag_fr = utf8_decode($child_row_detail[1]);
$tag_en = utf8_decode($child_row_detail[2]);
echo "<font size=\"1\">[<a href=\"$canon/?delete=$tag_id\">x</a>] $tag_fr ($tag_en), </font>";
}
}
}
}