PHP / SQL如何显示列表的最高出价

时间:2018-04-15 13:46:20

标签: php mysql sql mysqli

https://imgur.com/a/PYokL

您好,我知道目前我的数据库中有一些重复的列,因为我遇到了一些错误,我只是想让我的网站正常运行。我目前正在努力展示一个上市的最高出价。我很惊讶我如何找到每个特定列表的最高出价,因为出价似乎都捆绑在一个表中。我想知道是否有人可以帮我做此?

<?php
    require 'config.php';
    if(isset($_POST['submit']))
    {
        $valueToSearch = $_POST['valueToSearch'];
        // search in all table columns
        // using concat mysql function
        $query = "SELECT * FROM listings` WHERE CONCAT(`location`, `description`, `price`, `date`,`title`) LIKE '%".$valueToSearch."%'";
        $query2 = "SELECT `listID` FROM listings"
        $search_result = filterTable($query);

    }
     else {
        $query = "SELECT * FROM `listings`";
        $search_result = filterTable($query);
    }

    // function to connect and execute the query
    function filterTable($query)
    {
        $conn = mysqli_connect("localhost", "root", "", "auction");
        $filter_Result = mysqli_query($conn, $query);
        return $filter_Result;
    }

    ?>
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <title>Bid4MyJob</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Bid4MyJob">
        <meta name="author" content="James Wood">
        <!-- CSS -->
        <link href="assets/css/bootstrap.css" rel="stylesheet" type="text/css">
        <link href="assets/css/font-awesome.min.css" rel="stylesheet" type="text/css">
        <link href="assets/css/main.css" rel="stylesheet" type="text/css">
        <link href="assets/css/my-custom-styles.css" rel="stylesheet" type="text/css">

        <!-- IE 9 Fallback-->
        <!--[if IE 9]>
            <link href="assets/css/ie.css" rel="stylesheet">
        <![endif]-->
        <!-- GOOGLE FONTS -->
        <link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400italic,400,600,700' rel='stylesheet' type='text/css'>
        <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400italic,700,400,300' rel='stylesheet' type='text/css'>
        <!-- FAVICONS -->
        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/repute144x144.png">
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/repute114x114.png">
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/repute72x72.png">
        <link rel="apple-touch-icon-precomposed" href="assets/ico/repute57x57.png">
        <link rel="shortcut icon" href="assets/ico/favicon.png">
    </head>

    <body>
        <!-- WRAPPER -->
        <div class="wrapper">
            <!-- NAVBAR -->
            <nav class="navbar navbar-default " role="navigation">
                <div class="container">
                    <!-- TOPBAR -->
                    <div class="topbar">
                        <ul class="list-inline top-nav">
                            <li>
                                <div class="btn-group">
                                    <button type="button" class="btn btn-link dropdown-toggle btn-xs" data-toggle="dropdown"><img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom <span class="caret"></span></button>
                                    <ul class="dropdown-menu dropdown-menu-right country-selector" role="menu">
                                        <li>
                                            <a href="#"><img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom</a>
                                        </li>
                                        <li>
                                            <a href="#"><img src="assets/img/flags/Japan.png" alt="Japan"> Japan</a>
                                        </li>
                                        <li>
                                            <a href="#"><img src="assets/img/flags/China.png" alt="China"> China</a>
                                        </li>
                                        <li>
                                            <a href="#"><img src="assets/img/flags/Germany.png" alt="Germany"> Germany</a>
                                        </li>
                                    </ul>
                                </div>
                            </li>
                            <li><a href="#">Help</a></li>
                            <li><a href="#">Support</a></li>
                        </ul>
                        <div class="searchbox">
                            <form method="post">
                                <div class="input-group input-group-sm">
                                    <input type="text" class="form-control" placeholder="search ...">
                                    <span class="input-group-btn">
                                        <button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>
                                    </span>
                                </div>
                            </form>
                        </div>
                    </div>
                    <!-- END TOPBAR -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-nav">
                            <span class="sr-only">Toggle Navigation</span>
                            <i class="fa fa-bars"></i>
                        </button>
                        <a href="index.html" class="navbar-brand navbar-logo navbar-logo-bigger">

                        </a>
                    </div>
                    <!-- MAIN NAVIGATION -->
                    <div id="main-nav" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav navbar-right">
                            <li>
                                <a href="index.php">HOME</a>
                            </li>
                            <li>
                                <a href="HIW.php">HOW IT WORKS</a>
                            </li>
                            <li>
                                <a href="postjob.php">POST JOB</a>
                            </li>
                            <li>
                                <a href="findjob.php">FIND JOB</a>
                            </li>
                            <li>
                                <a href="signup.php">SIGN UP</a>
                            </li>
                            <li>
                                <a href="login.php">LOGIN</a>
                            </li>
                        </ul>
                    </div>
                    <!-- END MAIN NAVIGATION -->
                </div>
            </nav>
            <!-- END NAVBAR -->
            <!-- BREADCRUMBS -->
            <div class="page-header">
                <div class="container">
                    <h1 class="page-title pull-left">Find Job</h1>
                    <ol class="breadcrumb">
                        <li><a href="#">Home</a></li>
                        <li class="active">Find Job</li>
                    </ol>
                </div>
            </div>
            <!-- END BREADCRUMBS -->
            <!-- PAGE CONTENT -->
            <div class="page-content page-search-result">
                <div class="container">
                    <!-- Search Form -->
                    <form class="form form-horizontal" action="findjob.php" method="post">
                        <div class="input-group input-group-lg">
                            <div class="input-group-btn">
                                <!--<select id="search-type-select" name="valueToSearch" class="multiselect multiselect-single-lg search-type-select">
                                    <option value="all" selected="selected">All</option>
                                    <option value="page">Page</option>
                                    <option value="task">Task</option>
                                    <option value="user">User</option>
                                    <option value="image">Image</option>
                                </select>
                            </div>-->
                            <input class="form-control input-lg" type="text" name="valueToSearch" placeholder="type keyword ..." />
                            <span class="input-group-btn">
                            <button type="submit" name= "submit" value="Search" class="btn btn-primary btn-lg"><i class="icon ion-android-search"></i> Go</button>
                        </span>
                        </div>

                    </form>
                    <!-- End Search Form -->

                </div>
            </div>
            <div>
                <table>
                    <tr>
                        <th>Title</th>
                        <th>Location</th>
                        <th>Description</th>
                        <th>Budget</th>
                        <th>Due date</th>
                    </tr>

          <!-- populate table from mysql database -->
                    <?php while($row = mysqli_fetch_array($search_result)):?>
                    <tr>
                        <td><?php echo $row['title'];?></td>
                        <td><?php echo $row['location'];?></td>
                        <td><?php echo $row['description'];?></td>
                        <td><?php echo $row['price'];?></td>
                        <td><?php echo $row['date'];?></td>
                        <td><form method="post" action="actionpage5.php" class="form-horizontal">
                            <?php //echo _("Enter ") . ' ' . $last_bid_plus . ' ' . _('or more'); ?>

                            <div class="input-group ">

                            <input type="number" value="bid" class="form-control" name="bid" id= "bid" required/>
                            </div>
                            <br/>
                            <input type="submit" name="sb_bid" value="<?php echo _('Place your Bid'); ?>"
                                   class="btn btn-xlarge btn-block btn-primary"/>
                            <br/>
                        </form></td>
                    </tr>
                    <?php endwhile;?>
                </table>
            </div>
            <!-- END PAGE CONTENT -->
            <!-- FOOTER -->
            <footer>
                <div class="container">
                    <div class="row">
                        <div class="col-md-4">
                            <!-- COLUMN 1 -->
                            <h3 class="sr-only">ABOUT US</h3>
                            <img src="assets/img/logo/repute-logo-light.png" class="logo" alt="Repute">
                            <p>Proactively aggregate B2B initiatives before extensive channels. Monotonectally extend interactive methods of empowerment through excellent applications. Rapidiously synergize visionary products with sticky technology.</p>
                            <br>
                            <address class="margin-bottom-30px">
                                <ul class="list-unstyled">
                                    <li>Unit 5, Block B Nesfield Road
                                        <br/> Colchester, Essex CO4 3ZL 222222</li>
                                    <li>Phone: 01206 588 000</li>
                                    <li>Email: sales@universalwebdesign.co.uk</li>
                                </ul>
                            </address>
                            <!-- END COLUMN 1 -->
                        </div>
                        <div class="col-md-4">
                            <!-- COLUMN 2 -->
                            <h3 class="footer-heading">USEFUL LINKS</h3>
                            <div class="row margin-bottom-30px">
                                <div class="col-xs-6">
                                    <ul class="list-unstyled footer-nav">
                                        <li><a href="#">About Us</a></li>
                                        <li><a href="#">News</a></li>
                                        <li><a href="#">Community</a></li>
                                        <li><a href="#">Career</a></li>
                                        <li><a href="#">Blog</a></li>
                                    </ul>
                                </div>
                                <div class="col-xs-6">
                                    <ul class="list-unstyled footer-nav">
                                        <li><a href="#">Press Kit</a></li>
                                        <li><a href="#">FAQ</a></li>
                                        <li><a href="#">Terms</a></li>
                                        <li><a href="#">Privacy Policy</a></li>
                                        <li><a href="#">Contact Us</a></li>
                                    </ul>
                                </div>
                            </div>
                            <!-- END COLUMN 2 -->
                        </div>
                        <div class="col-md-4">
                            <!-- COLUMN 3 -->
                            <div class="newsletter">
                                <h3 class="footer-heading">NEWSLETTER</h3>
                                <p>Get the latest update from us by subscribing to our newsletter.</p>
                                <form class="newsletter-form" method="POST">
                                    <div class="input-group input-group-lg">
                                        <input type="email" class="form-control" name="email" placeholder="youremail@domain.com">
                                        <span class="input-group-btn"><button class="btn btn-primary" type="button"><i class="fa fa-spinner fa-spin"></i><span>SUBSCRIBE</span></button>
                                        </span>
                                    </div>
                                    <div class="alert"></div>
                                </form>
                            </div>
                            <div class="social-connect">
                                <h3 class="footer-heading">GET CONNECTED</h3>
                                <ul class="list-inline social-icons">
                                    <li><a href="#" class="facebook-bg"><i class="fa fa-facebook"></i></a></li>
                                    <li><a href="#" class="twitter-bg"><i class="fa fa-twitter"></i></a></li>
                                    <li><a href="https://plus.google.com/115190620540200390059" class="googleplus-bg"><i class="fa fa-google-plus"></i></a></li>
                                    <li><a href="#" class="rss-bg"><i class="fa fa-rss"></i></a></li>
                                </ul>
                            </div>
                            <!-- END COLUMN 3 -->
                        </div>
                    </div>
                </div>
                <!-- COPYRIGHT -->
                <div class="text-center copyright">
                    &copy;2018 Bid4MyJob. All Rights Reserved.
                </div>
                <!-- END COPYRIGHT -->
            </footer>
            <!-- END FOOTER -->
        </div>
        <!-- END WRAPPER -->
        <!-- JAVASCRIPTS -->
        <script src="assets/js/jquery-2.1.1.min.js"></script>
        <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/plugins/bootstrap-multiselect/bootstrap-multiselect.js"></script>
        <script src="assets/js/plugins/autohidingnavbar/jquery.bootstrap-autohidingnavbar.min.js"></script>
        <script src="assets/js/repute-scripts.js"></script>

    </body>

    </html>

1 个答案:

答案 0 :(得分:0)

$ query =“SELECT MAX(出价)FROM商品信息WHERE CONCAT(地点,说明,价格,日期, title`)LIKE'%” 。$ valueToSearch。“%'GROUP BY listing”