简体   繁体   English

通过PHP的数据库帮助

[英]Database help via PHP

I'am a total noob when it comes to programming, i can read and write a bit of HTML, but thats it. 在编程方面,我完全是个菜鸟,我可以读写一点HTML,但是仅此而已。 I need help with creating a new undersite for my webpage http://findaphone.dk where you'll be able to watch all models instead of only the ones that matches your answers. 在为我的网页http://findaphone.dk创建一个新的网站时,我需要帮助,在这里您将能够观看所有模型,而不仅仅是观看与您的答案匹配的模型。 The original idea behind the page, were that you could get help finding the smartphone that matches your preferences, but as I see the aren't really converting, i will give the users the ability to go to a page where they can see all models that we offer on the site. 该页面背后的原始想法是,您可以得到帮助来找到符合您的偏好的智能手机,但是正如我所见,这并没有真正转变,我将使用户能够转到一个页面,在该页面上可以看到所有型号我们在网站上提供的。

I think coding wise, it should be pretty simple, because the code is already written, but instead of sorting of phones, as it does now, it should simply show all available opportunities. 我认为编码是明智的,因为它已经编写了代码,所以应该非常简单,但是它不像现在那样对电话进行排序,而是应该简单地显示所有可用的机会。 My PHP code looks like this right now: 我的PHP代码现在看起来像这样:

// Main First Search (4 Questions)
    public function filter()
    {


        $price = $this->input->post('price');
        if ($price == '3000') {
            $price2 = '0';
        } else if ($price == '5500') {
            $price2 = '3000';
        } else if ($price == '6000') {
            $price = '10000';
            $price2 = '3500';
        }
        $size = $this->input->post('size');
        $type = $this->input->post('type');
        $design = $this->input->post('design');

        //echo "SELECT * FROM `product_info` WHERE `ac_price` > $price2 AND `ac_price` <= $price AND `design` = '$type' AND `size` = '$size' AND `type` = '$design' GROUP BY `id` ORDER BY `rating` DESC";die;
        $filter = $this->queries->custom("SELECT * FROM `product_info` WHERE `ac_price` > $price2 AND `ac_price` <= $price AND `design` = '$type' AND `size` = '$size' AND `type` = '$design' GROUP BY `id` ORDER BY `rating` DESC");


        if ($filter == null) {
            echo '';
        }

I think thats the part where the site chooses the phones that matches the answers from the database. 我认为那是网站选择与数据库答案匹配的电话的部分。 If not please tell me how it should look like. 如果没有,请告诉我它的外观。 Thanks for your help in advance!! 谢谢您的帮助!

Take a look at your SQL query. 看一下您的SQL查询。 The query includes the search parameters you've created earlier in the code - logically, by removing WHERE queries from your statement, you're removing limitations in the search. 该查询包含您先前在代码中创建的搜索参数-从逻辑上讲,通过从语句中删除WHERE查询,可以消除搜索中的限制。

$filter = $this->queries->custom("SELECT * FROM `product_info` GROUP BY `id` ORDER BY `rating` DESC");

Without WHERE queries, you're now selecting all elements from product_info , grouping by ID and ordering by rating. 如果没有WHERE查询,您现在可以从product_info中选择所有元素,按ID分组并按等级排序。

For more basic MySQL help take a look at http://arachnoid.com/MySQL/ 有关更基本的MySQL帮助,请访问http://arachnoid.com/MySQL/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM