Mailinglisten-Archive |
Aloha, > ---------- > Von: Christoph M. Schönian[SMTP:schoenian_(at)_mediaforce.de] > > $res = mysql_query( "select * from $table"); > $result = mysql_num_rows($res); > srand((double)microtime()*1000000); > $id = rand(1, $result); > $query = mysql_query( "select * from $table where id = $id"); > $row = mysql_fetch_array($query); > $id = $row[id]; > > ABER WIE muss das ganze aussehen, wenn ich nur bestimmte > Datensätze (Where image_start != "none") in den Zufallsgenerator > werfen moechte ??? > Ungetestet: ======== > $res = mysql_query( "select * from $table where image_start != > 'none'"); > $result = mysql_num_rows($res); > srand((double)microtime()*1000000); > $id = rand(1, $result); > $query = mysql_query( "select * from $table where where image_start != > 'none'"); mysql_data_seek($query, $id); > $row = mysql_fetch_array($query); > $id = $row[id]; > Manual: mysql_data_seek mysql_data_seek -- Move internal result pointer Description int mysql_data_seek(int result_identifier, int row_number); Returns: true on success, false on failure mysql_data_seek() moves the internal row pointer of the MySQL result associated with the specified result identifier to point to the specified row number. The next call to mysql_fetch_row() would return that row. Schiebt einfach das Statementhandle (im PHP-Jargon result_identifier ;) auf die Zeile row_number, damit erhältst du mit dem nächsten mysql_fetch das gewählte Element. Viele Grüße, Mathias
php::bar PHP Wiki - Listenarchive