|
Posted by Ja NE on 06/12/06 14:58
hello (again).
here is something I have slighlty idea how to do, but so far (after few
days) I haven't found the right way to do it.
have a mysql query for id,name,text and than, in while loop I'm printing
those data. that is easy part.
Now, I would like to shufle only names...
so, I have, for example:
1, john, some text;
2, mony, some other text;
3, nick, yet another text;
4, adry, one more text line;
and would like to have:
1, nick, some text;
2, adry, some other text;
3, john, yet another text;
4, mony, one more text line;
I think I would need to create some (one or more? first dilema)
array(s)...
for short, solution I have:
$query = "SELECT id,name,text FROM...";
$result = mysql_query($query);
while(list($id,$name,$text) = mysql_fetch_array($result)) {
echo"<tags>$id<>$name<>$text</tags>";
}
....and than to shufle names array...
for short, one of ideas (doesn't work...):
while(list($id,$name,$text) = mysql_fetch_array($result)) {
$namearr[$id] = $name;
sort($namearr);
$textarr[$id] = $text;
sort($textarr);
}
shufle($namearr);
foreach($namearr as $id => $name) {
foreach($textarr as $id => $text) {
echo"<tags>$id<>$name<>$text</tags>";
}
}
don't kill me please, php is only hobby for me...
tnx for any solution :)
--
Ja NE
http://fotozine.org/?omen=janimir
--
[Back to original message]
|