Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- connection
- <?php
- $severname = 'localhost';
- $serverusername = 'root';
- $serverpassword = '';
- $dbname = 'truck';
- $conn = mysqli_connect($severname,$serverusername,$serverpassword,$dbname);
- if (!$conn){
- die("Connection Failed");
- }
- else{
- //echo "echo databae connected ";
- }
- ?>
- Insert
- $sql = "INSERT INTO add_truck (truck_id, truck_number, truck_model, truck_make, truck_type, truck_tierweight, truck_gvm, truck_regodate, truck_inspectaiondate)
- VALUES ('$truck_id', '$truck_number', '$truck_model', '$truck_make', '$truck_type', '$truck_tierweight','$truck_gvm', '$truck_regodate', '$truck_inspectaiondate')";
- if (mysqli_query($conn,$sql))
- {
- echo "Record updated Successfully";
- }
- else
- {
- echo $sql."<br>".mysqli_error($conn);
- }
- Select:
- $sql= 'Select*from add_truck';
- $result=$conn->query($sql);
- if ($result->num_rows > 0) {
- ?>
- <table border="2">
- <thead>
- <tr>
- <th>Truck_id</th>
- <th>Truck_number</th>
- <th>Truck_model</th>
- <th>Truck_make</th>
- <th>Truck_type</th>
- <th>Truck_tierweight</th>
- <th>Truck_gvm</th>
- <th>Truck_regodate</th>
- <th>Truck_inspectaiondate</th>
- <th>View/Edit</th>
- </tr>
- </thead>
- <?php
- while($row = $result->fetch_assoc()) {
- ?>
- <tr>
- <td> <?php echo $row["truck_id"];?> </td>
- <td> <?php echo $row["truck_number"];?></td>
- <td> <?php echo $row["truck_model"];?></td>;
- <td> <?php echo $row["truck_make"];?></td>
- <td> <?php echo $row["truck_type"];?></td>
- <td> <?php echo $row["truck_tierweight"];?></td>
- <td> <?php echo $row["truck_gvm"];?></td>
- <td> <?php echo $row["truck_regodate"];?></td>
- <td> <?php echo $row["truck_inspectaiondate"];?> </td>;
- <td> <a href ='viewsingletruck.php?truck_id=$truck_id'>Update</a>
- </tr>
- <?php }
- }
- else {
- echo "0 results";
- }
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement