how to randomize unique id from table?
i have id, path, file as field names
i want something likeHTML Code:<option value="path/file">[I]random id[/I]</option>
how to randomize unique id from table?
i have id, path, file as field names
i want something likeHTML Code:<option value="path/file">[I]random id[/I]</option>
Please don't mind me. I am just posting a lot of nonsense.
I don't quite understand. Do you want to select a random existing ID from the table, or create a new one?
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
sorryOriginally Posted by Twey
existing random id from table
![]()
Please don't mind me. I am just posting a lot of nonsense.
Code:$rs = mysql_query('select id from tablename;'); $randomId = array(); while($row = mysql_fetch_array($rs)) array_push($randomId, $row['id']); $randomId = $randomId[rand(0, count($randomId))];
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
sorrybut where will i put it?
Code:<?php $result = mysql_query($qStr); $NumRows = mysql_num_rows($result); ?><body bgcolor="black" text="white" alink="green" vlink="red" link="blue"> <form name="dynamicselector"> <table border="0" width="100%" cellspacing="0" cellpadding="0" height="178"> <tr> <td width="35%" valign="top" align="left"> <select name="dynamicselector2" size="<?= strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") != false ? "1" : "2" ?>" onChange="generateimage(this.options[this.selectedIndex].value)"> <?php while( $row = mysql_fetch_array($result)) { echo "<option value=\"{$row[1]}/{$row[2]}\">{$row[0]}</option>\n"; }// $row[0] here is where random id part should go ?> </select> </td> <td width="65%" valign="top" align="left"><ilayer id="dynamic1" width=100% height=178><layer id="dynamic2" width=100% height=178><div id="dynamic3"></div></layer></ilayer></td> </tr> </table> </form> <script> //Dynamic Image selector Script- © Dynamic Drive (www.dynamicdrive.com) //For full source code, installation instructions, //100's more DHTML scripts, visit dynamicdrive.com var ie4=document.all var ns6=document.getElementById var tempobj=document.dynamicselector.dynamicselector2 if (ie4||ns6) var contentobj=document.getElementById? document.getElementById("dynamic3"): document.all.dynamic3 function generateimage(which){ if (ie4||ns6){ contentobj.innerHTML='<center>Loading image...</center>' contentobj.innerHTML='<center><img src="'+which+'"><br><br></center>' } else if (document.layers){ document.dynamic1.document.dynamic2.document.write('<center><img src="'+which+'"><br><br></center>') document.dynamic1.document.dynamic2.document.close() } else alert('You need NS 4+ or IE 4+ to view the images!') } function generatedefault(){ generateimage(tempobj.options[tempobj.options.selectedIndex].value) } if (ie4||ns6||document.layers){ if (tempobj.options.selectedIndex!=-1){ if (ns6) generatedefault() else window.onload=generatedefault } } </script><?php mysql_close($svrConn);?>
Please don't mind me. I am just posting a lot of nonsense.
Ah, I see. You want to just order the results randomly? Try adding ORDER BY RAND() to the end of your query.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
okiesthx
![]()
Please don't mind me. I am just posting a lot of nonsense.
how do i now return results randomly in PostgreSQL?tried adding ORDER BY RAND() to the end of the query. returns an error "function rand() does not exist"
any ideas?![]()
Please don't mind me. I am just posting a lot of nonsense.
In PostgreSQL the function is called RANDOM().
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks