2017-07-04 48 views
0

我開發一個應用程序(網上汽車銷售管理系統),我在DB插入數據並顯示一個頁面上所有的紀錄,但我有一個問題,我想通過點擊按鈕選擇一個記錄並顯示它的另一頁...我想要顯示另一頁上我的數據單擊按鈕

這裏是代碼:

<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> 
+0

把記錄的ID作爲價值'

+0

所以基本上你不知道如何提交一個表單? –

+0

不要再使用已棄用的'mysql_'函數。 – Marcel

回答

0

試試這個:

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