Javascript $selected在重新加载后不显示,但保存在数据库中

Javascript $selected在重新加载后不显示,但保存在数据库中,javascript,php,select,option,taxonomy,Javascript,Php,Select,Option,Taxonomy,我有一个php脚本: <select name="product_type_google" id="product_type_google" style="width: 300px;"> <?php require_once plugin_dir_path( __FILE__ ) . 'google_taxanomy.php'; $vybrane_google = $_POST["product_type_google"];

我有一个php脚本:

<select name="product_type_google" id="product_type_google" style="width: 300px;">
    <?php
        require_once plugin_dir_path( __FILE__ ) . 'google_taxanomy.php';
        $vybrane_google = $_POST["product_type_google"];
        $g1 = '';
        $g2 = '';

        foreach ( _g_google_gelect_options() as $moznost_google ) {
            $google_hodnota = $moznost_google['google_hodnota'];
            if ( $vybrane_google == $moznost_google['google_hodnota'] ) // Make default first in list
                $g1 .= "\n\t<option style=\"padding-right: 10px;\" selected='selected' value='" . esc_attr( $moznost_google['google_hodnota'] ) . "'>$google_hodnota</option>";
            else
                $g2 .= "\n\t<option style=\"padding-right: 10px;\" value='" . esc_attr( $moznost_google['google_hodnota'] ) . "'>$google_hodnota</option>";
        }
        echo $g1 . $g2;
    ?></select>
从kategorie.php和该文件中,有google分类法,例如:

function _g_google_gelect_options() {
    $google_gelect_options = array(
        '0' => array( 'value' => '0', 'label' => '' ),
        '1    ' => array( 'value' =>    '1    ', 'label' => __( 'Animals & Pet Supplies', '_g' ) ), 
        '2    ' => array( 'value' =>    '2    ', 'label' => __( 'Animals & Pet Supplies &gt; Live Animals', '_g' ) ), 
        '3    ' => array( 'value' =>    '3    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies', '_g' ) ), 
        '4    ' => array( 'value' =>    '4    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies &gt; Bird Supplies', '_g' ) ), 
        '5    ' => array( 'value' =>    '5    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies &gt; Bird Supplies &gt; Bird Cages & Stands', '_g' ) ), 
        '6    ' => array( 'value' =>    '6    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies &gt; Bird Supplies &gt; Bird Food', '_g' ) ), 
这个文件包含超过5800行!可能是因为它?我应该使用一些JavaScript吗


你能帮我吗?谢谢

示例选择选项有什么作用?对不起,我复制了我代码中不好的部分。现在我改变了函数的这一部分,你应该清楚了。请原谅,尝试将if$vybrane\u google==$moznost\u google['google\u hodnota']更改为if$vybrane\u google==esc\u attr$moznost\u google['google\u hodnota']这并没有解决我的问题:仍然没有显示google\u hodnota不在您的数组中
function _g_google_gelect_options() {
    $google_gelect_options = array(
        '0' => array( 'value' => '0', 'label' => '' ),
        '1    ' => array( 'value' =>    '1    ', 'label' => __( 'Animals & Pet Supplies', '_g' ) ), 
        '2    ' => array( 'value' =>    '2    ', 'label' => __( 'Animals & Pet Supplies &gt; Live Animals', '_g' ) ), 
        '3    ' => array( 'value' =>    '3    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies', '_g' ) ), 
        '4    ' => array( 'value' =>    '4    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies &gt; Bird Supplies', '_g' ) ), 
        '5    ' => array( 'value' =>    '5    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies &gt; Bird Supplies &gt; Bird Cages & Stands', '_g' ) ), 
        '6    ' => array( 'value' =>    '6    ', 'label' => __( 'Animals & Pet Supplies &gt; Pet Supplies &gt; Bird Supplies &gt; Bird Food', '_g' ) ),