$handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $arWords = split(",", $contents); if (count($arWords) < 2) { $arWords = split("\n", $contents); } //print(count($arWords)); for ($i = 0; $i < count($arWords); $i++) { $nm = $arWords[$i]; $cd = rand(123456, 987654); $sql = "INsert into RandomWords(item_nm,item_cd) Values('" . $nm . "','" . $cd . "')"; mysql_query($sql); } fclose($handle); } getDataFromDB($_GET["mask"]); mysql_close($link); //print one level of the tree, based on parent_id function getDataFromDB($mask) { $sql = "SELECT DISTINCT item_nm FROM RandomWords Where item_nm like '" . mysql_real_escape_string($mask) . "%'"; $sql .= " Order By item_nm LIMIT " . $_GET["pos"] . ",100"; if ($_GET["pos"] == 0) { print "<complete>"; } else { print "<complete add='true'>"; } $res = mysql_query($sql); if ($res) { while ($row = mysql_fetch_array($res)) { print "<option value=\"" . $row["item_nm"] . "\">";
$res = mysql_query($sql); if (!$res) { echo mysql_errno() . ": " . mysql_error() . " at " . __LINE__ . " line in " . __FILE__ . " file<br>"; } else { populateDBRendom(); } } //sleep(10); $fields = array("item_nm", "", "item_cd"); if (!isset($_GET["orderBy"])) { $_GET["orderBy"] = 0; } if (!isset($_GET["direction"])) { $_GET["direction"] = "ASC"; } getDataFromDB('', '', $fields[$_GET["orderBy"]], $_GET["direction"]); mysql_close($link); //populate db with 10000 records function populateDBRendom() { $filename = getcwd() . "/longtext.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $arWords = split(" ", $contents); //print(count($arWords)); for ($i = 0; $i < count($arWords); $i++) { $nm = $arWords[$i]; $cd = rand(123456, 987654); $sql = "INsert into Grid(item_nm,item_cd) Values('" . $nm . "','" . $cd . "')"; mysql_query($sql); if ($i == 9999) {
$handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $arWords = split("\r\n", $contents); //print(count($arWords)); for ($i = 0; $i < count($arWords); $i++) { $nm = $arWords[$i]; $cd = rand(123456, 987654); $sql = "INsert into Countries(item_nm,item_cd) Values('" . $nm . "','" . $cd . "')"; mysql_query($sql); if ($i == 9999) { break; } } fclose($handle); } getDataFromDB($_REQUEST["mask"]); mysql_close($link); //print one level of the tree, based on parent_id function getDataFromDB($mask) { $sql = "SELECT DISTINCT item_nm FROM Countries Where item_nm like '" . mysql_real_escape_string($mask) . "%'"; $sql .= " Order By item_nm LIMIT " . $_REQUEST["pos"] . ",20"; if ($_REQUEST["pos"] == 0) { print "<complete>"; } else { print "<complete add='true'>"; } $res = mysql_query($sql); if ($res) { while ($row = mysql_fetch_array($res)) { print "<option value=\"" . $row["item_nm"] . "\">";