SHARE
TWEET

poji

a guest Sep 10th, 2019 173 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $servername = 'localhost';
  4. $username = 'root';
  5. $password = '';
  6. $dbname = 'todolist';
  7.  
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9.  
  10. if(!$conn){
  11.     die('Connection failed:' . mysqli_connect_error());
  12. }
  13.  
  14. //echo 'Connected successfully!';
  15.  
  16. /*$sql = "INSERT INTO tasks (name, description, dateCreated, dateUpdated) VALUES ('BREAKFAST' , 'NASI LEMAK' , NOW(), NOW())";
  17.  
  18. if(mysqli_query($conn, $sql)){
  19.     echo 'New record created successfully';
  20. } else{
  21.     echo 'Error' . $sql . "<br>" . mysqli_error($conn);
  22. }
  23. */
  24.  
  25. $sql = 'SELECT taskId, name, description, dateCreated, dateUpdated FROM tasks';
  26. $result = mysqli_query($conn, $sql);
  27.  
  28. if(myqsli_num_rows($result) > 0){
  29.     while($row = mysqli_fetch_assoc($result)){
  30.         echo 'TaskId:' . $row['id'] . '-Name:' . $row['name'] . '-Description:' . $row['description'] ."<br>";
  31.     }
  32. }   else{
  33.     echo '0 results';
  34. }
  35.  
  36. mysqli_close($conn);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top