RE: [PHP] mysql_data_seek in a FOR loop
| From: | John W. Holmes | Date: | Tue, 22 Oct 2002 16:26:31 +0000 |
| Subject: | RE: [PHP] mysql_data_seek in a FOR loop | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120940@lists.php.net to get a copy of this message | ||
Easiest way to do this, I've found, is with nested tables. Have one
table with a left and right column. Each column would have a table
within it that prints the results top to bottom. So the left hand
column's table would be the first X results and the right hand column's
table would be the next X results.
I don't know if that helps you or not... hope it does.
---John Holmes...
> -----Original Message-----
> From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
> Sent: Tuesday, October 22, 2002 12:11 PM
> To: 'PHP General'
> Subject: [PHP] mysql_data_seek in a FOR loop
>
> 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."
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php