Jump to content

PHP MYSQL -


Zorglub
 Share

Recommended Posts

Hi, I am trying to make a latest visited cars segment where I save the image and id of the car the the user sees. But I am lost as how to go from here...

 

    $servername = "localhost";
    $username = "root";
    $password = "Wichmand14";
    $dbname = "visited";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }

    $dateValue = date('d-m-Y H:i:s');
    $imgUrl = $vehicle->Pictures[1];

    $getTimeStamp = "SELECT timestamp FROM latest";
    $sql = "INSERT INTO latest (timestamp, vehicleid, img) VALUES ('$dateValue', '$vehicle->VehicleId', '$imgUrl')";

    if ($getTimeStamp->num_rows > 0) {
        // output data of each row
        while($row = $getTimeStamp->fetch_assoc()) {
                echo "Timestamp: " . $row['timestamp'];
        }
   }
    if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
    } else {
    echo "Error: " . $sql . "<br>" . $conn->error;
    }

    $conn->close();

 

Link to comment
Share on other sites

  • Barand locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.