To run with less overhead, I would advice to only access the database when
absolutely nessary. Therefor I would approach the problem with pasting the
database result into an array and then doing the work from here - an array
is much faster to work with rather than db.
An approach could be
<?php
$connect = mysql_connect("$host","$user","$pass") OR die(mysql_error());
$selectdb = mysql_select_db("$db") OR die(mysql_error());
$result = mysql_query("SELECT * FROM teams where week='$list' ORDER BY
date");
if (!mysql_num_rows($result)) {
die ("No results");
}
$res = array();
while($foo = mysql_fetch_row($result)) {
$res[] = $foo;
}
$resSize = sizeof($res);
# now add your code... loop through the array using
for ($i=0; $i<$resSize; $i++) {
echo $res[$i]["RowName"];
}
?>
/ Lars
LJWeb GmbH
www.ljweb.com
-----Original Message-----
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: 14. august 2001 13:40
To: Caleb Walker; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] start over on database read inorder to read from
the beggining again
> How can I run through a database like I am trying to do here? It seems
like
> at the end of the first I need to start over in order to start reading
from
> the beggining of the database on the second.
> I hope that I hace explained my problem well if not please reply with your
> questions. Thank you in advance.
>
> Caleb
> <!--Snip-->
> $connect = mysql_connect("$host","$user","$pass") OR (die("mysql_error"));
> $selectdb = mysql_select_db("$db") OR (die("mysql_error"));
> $result = mysql_query("SELECT * FROM teams where week='$list' ORDER BY
date");
> while($view = mysql_fetch_row($result))
> {
> code;
> }
> more code;
> and <html>
> while($view = mysql_fetch_row($result))
> {
> code;
> }
try adding:
mysql_data_seek($result, 0);
before your second loop. This should reset your dataset so you can loop
again.
regards
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] start over on database read inorder to read from the beggining again
Lars B. Jensen, LJ Webnologics Mon, 13 Aug 2001 21:27:47 -0700
- [PHP-DB] start over on database read inorde... Caleb Walker
- Re: [PHP-DB] start over on database re... Jason Wong
- Lars B. Jensen, LJ Webnologics
