Advertisement
ginvi

how to check data if exist

Jun 16th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. $db_host = 'localhost'; // Server Name
  5. $db_user = 'root'; // Username
  6. $db_pass = 'root'; // Password
  7. $db_name = 'node_update'; // Database Name
  8.  
  9. $conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
  10. if (!$conn) {
  11. die ('Failed to connect to MySQL: ' . mysqli_connect_error());
  12. }
  13. ?>
  14. <?php
  15.  
  16. if(isset($_POST['submit'])){
  17. $id=$_POST['id'];
  18. $node=$_POST['node'];
  19. $interface=$_POST['interface'];
  20. $filter=("SELECT node from cam where id ='$id'");
  21. $query = mysqli_query($conn, $filter);
  22.  
  23. }
  24. if(mysqli_num_rows($query)>1){
  25.  
  26. echo "this file exist".$node;
  27. /*
  28. DELETE CODE HERE!!
  29.  
  30. */
  31. }
  32. else{
  33.  
  34. /*
  35. update code here !!
  36. */
  37. echo "update this ! ";
  38.  
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement