473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mission impossibile (for me)

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
--
Jun 12 '06 #1
3 1227
Instead of using array random, use builtin mysql random :

SELECT id,name,text FROM table ORDER by RAND()

--
http://blog.deshot.com
http://www.groupvita.com

Jun 12 '06 #2
"lorento" <la**********@yahoo.com> wrote in message
news:11*********************@y43g2000cwc.googlegro ups.com...
Instead of using array random, use builtin mysql random :

SELECT id,name,text FROM table ORDER by RAND()

In the original post he said:
Now, I would like to shufle only names...


The names and text should be separated and shuffled. Your solution is just
shuffling the select order which is not what he wanted.

I think something like this could work:

$query1 = "SELECT id,text FROM...";
$result1 = mysql_query($query1);
$query2 = "SELECT name FROM... ORDER BY RAND()";
$result2 = mysql_query($query2);

while((list($id,$text) = mysql_fetch_array($result1)) && (list($name) =
mysql_fetch_array($result2)) ) {
echo"<tags>$id<>$name<>$text</tags>";
}
--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jun 13 '06 #3
Kimmo Laine <sp**@outolempi.net> wrote:
I think something like this could work:

$query1 = "SELECT id,text FROM...";
$result1 = mysql_query($query1);
$query2 = "SELECT name FROM... ORDER BY RAND()";
$result2 = mysql_query($query2);

while((list($id,$text) = mysql_fetch_array($result1)) && (list($name) =
mysql_fetch_array($result2)) ) {
echo"<tags>$id<>$name<>$text</tags>";
}


that hepled, tnx :)

--
Ja NE
http://fotozine.org/?omen=janimir
--
Jun 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony | last post by:
Question... I am preparing a presentation on Oracle for my Senior Capstone class at Colorado State University. Does ANYONE know Oracle's Mission Statement or have a link pointing to it...
2
by: BuonAngolo | last post by:
Ho trasportato sul Sql-Server del cliente: Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Standard Edition on Windows NT 5.2 (Build 3790: ) un db sviluppato su un mio sql-server di sviluppo:...
8
by: Frank Buss | last post by:
A new challenge: http://www.frank-buss.de/marsrescue/index.html Have fun! Now you can win real prices. -- Frank Buß, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
1
by: Jay | last post by:
The GOF text is widely considered the definitive book on the topic. Design Patterns: Elements of Reusable Object-Oriented Softare, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides ...
20
by: Drebin | last post by:
It's a long story really, but the bottom line is we need to encrypt or obfuscate a clear-text 9-digit SSN/taxpayer ID into something less than 21 characters. It doesn't need to be super-secure,...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
2
by: Ethan V | last post by:
My business people gave me a new requirement today : Have a button on a web page that allow users to synchronize their contact data that stored in our sql server with Outlook on their local...
0
by: =?Utf-8?B?c2Nvb3Q=?= | last post by:
I have a new install of FSX Deluxe that seems to run properly but once I fly a mission and hit Esc then click on End Mission, FSX seems to close and I have to relaunch it again as if starting a new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.