Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. connection
  2.  
  3. <?php
  4.  
  5. $severname = 'localhost';
  6. $serverusername = 'root';
  7. $serverpassword = '';
  8. $dbname = 'truck';
  9.  
  10. $conn = mysqli_connect($severname,$serverusername,$serverpassword,$dbname);
  11. if (!$conn){
  12. die("Connection Failed");
  13. }
  14.  
  15. else{
  16. //echo "echo databae connected ";
  17. }
  18. ?>
  19.  
  20.  
  21.  
  22.  
  23.  
  24. Insert
  25.  
  26. $sql = "INSERT INTO add_truck (truck_id, truck_number, truck_model, truck_make, truck_type, truck_tierweight, truck_gvm, truck_regodate, truck_inspectaiondate)
  27. VALUES ('$truck_id', '$truck_number', '$truck_model', '$truck_make', '$truck_type', '$truck_tierweight','$truck_gvm', '$truck_regodate', '$truck_inspectaiondate')";
  28. if (mysqli_query($conn,$sql))
  29. {
  30. echo "Record updated Successfully";
  31. }
  32. else
  33. {
  34. echo $sql."<br>".mysqli_error($conn);
  35. }
  36.  
  37.  
  38.  
  39. Select:
  40.  
  41. $sql= 'Select*from add_truck';
  42. $result=$conn->query($sql);
  43. if ($result->num_rows > 0) {
  44. ?>
  45. <table border="2">
  46. <thead>
  47. <tr>
  48. <th>Truck_id</th>
  49. <th>Truck_number</th>
  50. <th>Truck_model</th>
  51. <th>Truck_make</th>
  52. <th>Truck_type</th>
  53. <th>Truck_tierweight</th>
  54. <th>Truck_gvm</th>
  55. <th>Truck_regodate</th>
  56. <th>Truck_inspectaiondate</th>
  57. <th>View/Edit</th>
  58. </tr>
  59. </thead>
  60. <?php
  61. while($row = $result->fetch_assoc()) {
  62. ?>
  63. <tr>
  64. <td> <?php echo $row["truck_id"];?> </td>
  65. <td> <?php echo $row["truck_number"];?></td>
  66. <td> <?php echo $row["truck_model"];?></td>;
  67. <td> <?php echo $row["truck_make"];?></td>
  68. <td> <?php echo $row["truck_type"];?></td>
  69. <td> <?php echo $row["truck_tierweight"];?></td>
  70. <td> <?php echo $row["truck_gvm"];?></td>
  71. <td> <?php echo $row["truck_regodate"];?></td>
  72. <td> <?php echo $row["truck_inspectaiondate"];?> </td>;
  73. <td> <a href ='viewsingletruck.php?truck_id=$truck_id'>Update</a>
  74. </tr>
  75. <?php }
  76. }
  77. else {
  78. echo "0 results";
  79. }
  80. ?>
  81. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement