我想在另一个页面上显示我的数据,点击按钮

时间:2017-07-04 08:55:41

标签: php

我正在开发一个应用程序(在线车辆销售管理系统),我在数据库中插入数据并在单页上显示所有记录,但我有一个问题,我想通过点击按钮选择一个记录并显示另一个页面...

这是代码:

<html>
    <head>
        <title>New Purchase</title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <script src="js/jquery.js"></script>
        <script src="js/bootstrap.min.js"></script>

        <?php
        session_start();

        if (isset($_POST['logout'])) {
            session_destroy();
            header("location: ovsms.php");
        }
        ?>
    </head>
    <body>
        <div class="jumbotron container-fluid" style="background-color:#4E4A49; 
             padding-top:10px; padding-bottom:0px;" >

            <a href="home.php" ><img src="ovsms.jpg" style="width:100px;"></a>

            <a href="ovsms.php" name="logout" style="margin-left:925px;  padding-
               right:10px; color:#F7008C;"><span class="glyphicon glyphicon-log-out">
                </span> LogOut</a>



            <h1 style="text-align:center; padding-bottom:20px; margin-top:10px;
                margin-bottom:20px; font-family:Lucida Calligraphy; color:#0566c3;">Online 
                Vehicle Sales Management System</h1>    
        </div>
        <div  style="color:black; "class="btn-group btn-group-justified" >
            <a href="home.php" class="btn btn-primary" ><span class="glyphicon 
                                                              glyphicon-home"></span> Home</a>
            <a href="about.php" class="btn btn-primary"><span class="glyphicon 
                                                              glyphicon-education"></span> About Us</a>
            <a  href="contact.php" class="btn btn-primary"> <span class="glyphicon 
                                                                  glyphicon-envelope"></span> Contact Us</a>
        </div>

        <div class="list-group" style="width:250px; margin-left:10px;">
            <h3 style="text-align:center; color:#0566c3;">Vehicles for...?</h3>
            <a style=" color:#0566c3;" href="newpurchase.php" class="list-group-item 
               ">new purchase</a>
            <a style=" color:#0566c3;" href="rent.php" class="list-group-item">Rent</a>

        </div>

        <div class="container-fluid">
            <form action="" method="post" >
                <div class="form-group">
                    <input type="text"  name="srno" placeholder="Select by Sr.No  ....">

                </div>
                <div class="form-group">
                    <button type="submit" name="view" class="btn btn-default" 
                            style="color:#F7008C; background-color:#0566c3;" ><span class="glyphicon 
                                                                            glyphicon-ok"></span> Select</button>
                </div>
            </form>
        </div>



        <div>
            <h1 class="container" style="color:#0566c3;"><span class="glyphicon glyphicon-bed"></span> Vehicles for New Purchase</h1>
            <?php
            include('DbConnect.php');

            $sql = mysql_query("select * from vehicledata");
            while ($row = mysql_fetch_array($sql)) {
                ?>

                <table class="table table-striped" class="container-fluid" style="margin:10;">
                    <form action="newpurchase.php" method="post" enctype="multipart/form-data" >
                        <tbody>
                            <tr>
                        <div class="form-group">

                            <thead><img width='250' src="<?php echo $row['image']; ?>" /></thead>
                        </div>
                        </tr>
                        <tr><div class="form-group" >

                            <td>Sr.No <b><?php echo $row['id']; ?></b>
                            </td><td></td>
                        </div></tr>
                        <tr><div class="form-group" >
                            <td>Company</td>
                            <td><b><?php echo $row['company']; ?></b>
                            </td>
                        </div></tr>

                        <tr><div class="form-group">
                            <td>Vehicle Name</td>
                            <td><b><?php echo $row['vehiclename']; ?></b></td>
                        </div>
                        </tr>
                        <tr><div class="form-group">
                            <td>Model</td>
                            <td><b><?php echo $row['model']; ?></b></td>
                        </div></tr>
                        <tr>
                        <div class="form-group">
                            <td>Fuel Type</td>
                            <td><b><?php echo $row['fuel']; ?></b></td>
                        </div></tr>
                        <tr>
                        <div class="form-group">
                            <td>Transmission Type</td>
                            <td><b><?php echo $row['tranmission']; ?></b></td></div></tr>
                        <tr><div class="form-group">
                            <td>Engine</td>
                            <td><b><?php echo $row['engine']; ?></b></td></div></tr>
                        <tr><div class="form-group">
                            <td>Driving Type</td>
                            <td><b><?php echo $row['drive']; ?></b></td></div></tr>
                        <tr><div class="form-group">
                            <td>Mileage (Km/L)</td>
                            <td><b><?php echo $row['mileage']; ?></b> </td></div></tr>
                        <tr><div class="form-group">
                            <td>Price in Rs =/</td>
                            <td><b><?php echo $row['price']; ?></b></td></div></tr>
                        <tr><div class="form-group">


                            <td><br>
                                <button type="submit" name="add" class="btn btn-default" style="color:#F7008C; background-color:#0566c3;" ><span class="glyphicon glyphicon-ok"></span> Select</button>

                            </td><td></td>
                        </div></tr>
                        </tbody>
                    </form>
                </table>
                <?php
            }
            ?>
        </div>
        <?php
        if (isset($_POST['view'])) {

            $srno = $_POST['srno'];
            $select = mysql_query("select * from vehicledata where id='$srno' ");
            if ($ro = mysql_fetch_array($select)) {
                ?>
                <div class="container-fluid"><h1>Your dream car is here...</h1>

                    <h2>You have to pay <?php echo $ro['price']; ?></h2></div>
                <div>   <table class="table table-striped" class="container-fluid" style="margin:10;">
                        <form action="newpurchase.php" method="post" enctype="multipart/form-data" >
                            <tbody>
                                <tr>
                            <div class="form-group">

                                <thead><img width='250' src="<?php echo $ro['image']; ?>" /></thead>
                            </div>
                            </tr>
                            <tr><div class="form-group" >

                                <td></b>
                                </td><td></td>
                            </div></tr>
                            <tr><div class="form-group" >

                                <td>Sr.No <b><?php echo $ro['id']; ?></b>
                                </td><td></td>
                            </div></tr>
                            <tr><div class="form-group" >
                                <td>Company</td>
                                <td><b><?php echo $ro['company']; ?></b>
                                </td>
                            </div></tr>

                            <tr><div class="form-group">
                                <td>Vehicle Name</td>
                                <td><b><?php echo $ro['vehiclename']; ?></b></td>
                            </div>
                            </tr>
                            <tr><div class="form-group">
                                <td>Model</td>
                                <td><b><?php echo $ro['model']; ?></b></td>
                            </div></tr>
                            <tr>
                            <div class="form-group">
                                <td>Fuel Type</td>
                                <td><b><?php echo $ro['fuel']; ?></b></td>
                            </div></tr>
                            <tr>
                            <div class="form-group">
                                <td>Transmission Type</td>
                                <td><b><?php echo $ro['tranmission']; ?></b></td></div></tr>
                            <tr><div class="form-group">
                                <td>Engine</td>
                                <td><b><?php echo $ro['engine']; ?></b></td></div></tr>
                            <tr><div class="form-group">
                                <td>Driving Type</td>
                                <td><b><?php echo $ro['drive']; ?></b></td></div></tr>
                            <tr><div class="form-group">
                                <td>Mileage (Km/L)</td>
                                <td><b><?php echo $ro['mileage']; ?></b> </td></div></tr>
                            <tr><div class="form-group">
                                <td>Price in Rs =/</td>
                                <td><b><?php echo $ro['price']; ?></b></td></div></tr>

                            </tbody>
                        </form>
                    </table></div>

                <?php
            }
        }
        ?>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

试试这个:

<td>
  <a href='other page url?view=<?php echo  $row['id']; ?>'>View</a>
</td>