Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = 'localhost';
- $username = 'root';
- $password = '';
- $dbname = 'todolist';
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- if(!$conn){
- die('Connection failed:' . mysqli_connect_error());
- }
- //echo 'Connected successfully!';
- /*$sql = "INSERT INTO tasks (name, description, dateCreated, dateUpdated) VALUES ('BREAKFAST' , 'NASI LEMAK' , NOW(), NOW())";
- if(mysqli_query($conn, $sql)){
- echo 'New record created successfully';
- } else{
- echo 'Error' . $sql . "<br>" . mysqli_error($conn);
- }
- */
- $sql = 'SELECT taskId, name, description, dateCreated, dateUpdated FROM tasks';
- $result = mysqli_query($conn, $sql);
- if(myqsli_num_rows($result) > 0){
- while($row = mysqli_fetch_assoc($result)){
- echo 'TaskId:' . $row['id'] . '-Name:' . $row['name'] . '-Description:' . $row['description'] ."<br>";
- }
- } else{
- echo '0 results';
- }
- mysqli_close($conn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement