搜索没有城市的课程和国家

时间:2015-10-29 11:32:46

标签: mysql wordpress

感谢所有...... 还有一个问题是...... 我查询没有城市的搜索,选择课程和国家显示特定国家和该国所有城市的特定课程,其工作正常。但问题是当我两次进入同一个城市的相同路线并且搜索其显示的一个查询是很好的另一个查询它显示该特定国家的最后一个城市的名称和那个城市的id是什么问题。在wordpress。 我的代码是:

if($the_query->post_count > 0)
            {
                echo "post count".$the_query->post_count; echo "<br />";
                //echo "the query <br/>";


                for($i=0; $i < $the_query->post_count; $i++){ 

                $sql_city = "select name ,term_id from wp_terms where term_id = $x[$i]"; echo "<br />";
                echo $sql_city;
                $query_city = mysql_query($sql_city);
                if($row = mysql_fetch_array($query_city))
                 {
                    $term_id = $row['term_id'];
                    $name = $row['name'];
                 }  
                 echo $term_id;echo "<br />";
                 echo $name;

            ?>

             <tr>
                    <td><?php echo $the_query->posts[$i]->post_title; ?></td>
                    <td><?php echo strtoupper ($_SESSION['header_country']);  ?></td>
                    <td><?php if(empty($_POST['city']))
                    {echo strtoupper ($name);}
                    else
                    { echo strtoupper($_POST['city']);
                    } ?></td>
                    <?php /*?><td><?php echo strtoupper ($_POST['city']); ?></td><?php */?>
                    <td>
                            <a class="btn btn-primary" href="<?php echo $home_url."/course/".$the_query->posts[$i]->post_name; ?>">Know More</a>
            <a class="btn btn-warning"  href="<?php echo home_url(); ?>/shop/?add-to-cart=<?php echo $the_query->posts[$i]->ID; ?>">Enroll Now</a>
                   </td>
              </tr>
            <?php 
            } 
            }

0 个答案:

没有答案