· 6 years ago · Jan 21, 2020, 02:56 PM
1<?php
2$connect = mysql_connect("localhost","root","") or die ("Couldn't connect!");
3$createdb = mysql_query ("CREATE DATABASE detection");
4mysql_select_db("detection") or die ("Couldn't find db");
5
6$createtable = mysql_query ("
7CREATE TABLE IF NOT EXISTS `nodes` (
8 `nodid` int(5) NOT NULL AUTO_INCREMENT,
9 `index1` int(3) NOT NULL,
10 `index2` int(3) NOT NULL,
11 `x` double NOT NULL,
12 `y` double NOT NULL,
13 PRIMARY KEY (`nodid`)
14) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=401 ;
15");
16
17//create nodes table
18$nod=1;
19$nod1=1;
20$x=1;
21$y=1;
22
23while ($nod <= 10 )
24 {
25 while ($nod1 <=10)
26 {
27 $x=$x+(rand(1,5)/10);
28 $y=$y+(rand(1,5)/10);
29 echo "$nod-$nod1-$x-$y"."***";
30 $queryinsertrow = mysql_query ("
31 INSERT INTO nodes VALUES (' ', '$nod', '$nod1', '$x', '$y')
32 ");
33 $x=$x-(rand(1,5)/10);
34 $y=$y-(rand(1,5)/10);
35 $nod1++;
36 $x=$x+50;
37 }
38 echo "<br>";echo "<br>";
39 $nod++;
40 $y=$y+50;
41 $nod1=1;
42 $x=0;
43 }
44?>