RE: [PHP] mysql_data_seek in a FOR loop
| From: | John W. Holmes | Date: | Tue, 22 Oct 2002 16:36:51 +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-120946@lists.php.net to get a copy of this message | ||
I don't know. Honestly, I didn't really look at your code. I've never
used any of the seek() functions for databases. You should always be
able to pull out exactly what you want and just use arrays or HTML to
format it how you want it.
Speaking of arrays, why not use two arrays $left[] and $right[] to store
the data returned. Alternate the returned rows, the first goes in $left,
the second goes in $right, etc. Then you just use a regular table and
use:
<td>$left[$x]</td><td>$right[$x++]</td>
to display it? Wouldn't that work just as well and you wouldn't have to
worry about the nested tables?
---John Holmes...
> -----Original Message-----
> From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
> Sent: Tuesday, October 22, 2002 12:28 PM
> To: holmes072000@charter.net; 'PHP General'
> Subject: RE: [PHP] mysql_data_seek in a FOR loop
>
> Thanks John, looks like the way to go. OTOH I wonder why
mysql_data_seek
> doesn't work for this, hmmmmm.....
>
> -----Original Message-----
> From: John W. Holmes [mailto:holmes072000@charter.net]
> Sent: Tuesday, October 22, 2002 11:27 AM
> To: 'Jay Blanchard'; 'PHP General'
> Subject: RE: [PHP] mysql_data_seek in a FOR loop
>
>
> 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
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>