$result = mysql_query("SELECT FROM table WHERE `pid`=0 ORDER BY `priority` ASC") or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo $row['title_ru'] . "<br/>";
$res = mysql_query("SELECT FROM table WHERE `pid`={$row['id']} ORDER BY `pid` ASC, `priority` ASC") or die(mysql_error());
while($r = mysql_fetch_assoc($res))
echo $r['title_ru'] . "<br/>";
}
$n = rand(0, count($result_array) - 1)
<?
$ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$lettersCount = 4; //кол-во символов
$wordsCount = 1000000; //кол-во слов
$c = 0;
$result = array();
while(count($result) < $wordsCount && $c++ < 10)
{
$str = "";
for($i = 0; $i < $lettersCount; $i++)
$str .= $ABC[rand(0, strlen($ABC) - 1)];
$result[$str] = 1;
}
echo "Сгенерировано ".count($result)." строк";
?>
<?
function generate($depth = 0, $str = "")
{
global $ABC, $lettersCount, $c, $wordsCount;
if($depth == $lettersCount)
{
mysql_query("INSERT INTO `table` SET `value`='$str'");
$c++;
return;
}
for($i = 0; $i < strlen($ABC); $i++)
{
generate($depth + 1, $str.$ABC[$i]);
if($c == $wordsCount)
{
echo "Сгенерировано $c слов";
exit;
}
}
}
$ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$lettersCount = 4; //кол-во символов
$wordsCount = 1000000; //кол-во слов
$c = 0;
generate();
?>