Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2. //locate neighbours
  3. $connect = mysql_connect("localhost","root","") or die ("Couldn't connect!");
  4. mysql_select_db("detection") or die ("Couldn't find db");
  5.  
  6. $query=mysql_query ("SELECT * FROM nodes");
  7. while ($row=mysql_fetch_assoc($query))
  8. {
  9. $nodid=$row['nodid'];
  10. $x=$row['x'];
  11. $y=$row['y'];
  12. $name="station".$nodid;
  13. echo $name; echo "<br>";
  14.  
  15. $createtable = mysql_query ("
  16. CREATE TABLE `detection`.`".$name."` (
  17. `nid` INT( 5 ) NOT NULL ,
  18. `x` DOUBLE NOT NULL ,
  19. `y` DOUBLE NOT NULL ,
  20. `isnb` INT( 1 ) NOT NULL ,
  21. PRIMARY KEY ( `nid` )
  22. ) ENGINE = MYISAM ;
  23. ");
  24.  
  25. $query1=mysql_query ("SELECT * FROM nodes WHERE ($nodid>nodid) OR ($nodid<nodid)");
  26. while ($row1=mysql_fetch_assoc($query1))
  27. {
  28. $nodidneigh=$row1['nodid'];
  29. $xneigh=$row1['x'];
  30. $yneigh=$row1['y'];
  31. if ( (abs($x-$xneigh))<60 AND (abs($y-$yneigh))<60)
  32. {$isneigh=1;}
  33. else {$isneigh=0;}
  34.  
  35. $queryinsertrow = mysql_query ("
  36. INSERT INTO $name VALUES ('$nodidneigh','$xneigh','$yneigh','$isneigh')
  37. ");
  38.  
  39. }
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement