mysql_data_seek in a FOR loop

From: Date: Tue, 22 Oct 2002 16:11:24 +0000
Subject: mysql_data_seek in a FOR loop
Groups: php.general 
Request: Send a blank email to php-general+get-120937@lists.php.net to get a copy of this message
Where I have a DB return more than 10 rows of information I need to print two columns (actually four) of data, so side-by-side layout is needed. I tried using mysql_data_seek() to accomplish this, but to no avail. Can anyone see where I have gone wrong? $stat = "SELECT DISTINCT(event) AS eventname, COUNT(event) AS eventcount FROM tblHistory WHERE userID = '" . $userid . "' GROUP BY event "; if(!($dbstat = mysql_query($stat, $dbconnect))){ print("MySQL Error: " . mysql_error() . "\n"); exit(); } // print stats to page for user $numrows = mysql_num_rows($dbstat); print("<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"65%\">\n"); $statrow = mysql_fetch_object($dbstat); if($numrows > 10){ $seek1 = 0; $seek2 = 10; for($i = 1; $i <= 11; $i++){ print(" <tr bgcolor=\"#99FFFF\">\n"); print($seek1); mysql_data_seek($dbstat, "$seek1"); print(" <td>" . $statrow->eventname . "</td>\n"); print(" <td align=\"right\">" . $statrow->eventcount . "</td>\n"); mysql_data_seek($dbstat, $seek2); print($seek2); print(" <td>" . $statrow->eventname . "</td>\n"); print(" <td align=\"right\">" . $statrow->eventcount . "</td>\n"); print(" </tr>\n"); $seek1++; $seek2++; } } print("</table>\n"); Thanks in advance! Jay "Too much code, not enough sleep."

« previous php.general (#120937) next »