Zorglub Posted September 25, 2021 Share Posted September 25, 2021 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 More sharing options...
Barand Posted September 25, 2021 Share Posted September 25, 2021 Stop posting duplicates of this topic. Link to comment Share on other sites More sharing options...
Recommended Posts