Re: db looping?
| From: | James Kupernik | Date: | Fri, 18 Jan 2002 20:44:33 +0000 |
| Subject: | Re: db looping? | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15976@lists.php.net to get a copy of this message | ||
Thank you (as I slam my head against the desk several times)!
James
"James Chin" <jchin@openlinksw.com> wrote in message
news:a61h4uke39lm9gbai1q1jjdt50f37gvd8p@4ax.com...
> Hello James,
>
> You're passing you 'i' parameter to the URL incorrectly. PHP splits
> the paramer list into separate elements by looking for & characters,
> examining each element for the equal sign. Note this line, towards
> the end of the code:
> echo "<br><a href=\"$PHP_SELF?nextpg=good?i=$i\">Next ....
>
> You're separating the 'nextpg' and 'i' with a question mark. Change
> to this & and you should be all set.
>
> Regards,
> James Chin
> Technical Support Consultant
> OpenLink Software http://www.openlinksw.com
> Universal Data Access & Data Integration Technology Providers
>
> On Fri, 18 Jan 2002 14:02:51 -0500, kupernik@bcn.net (James Kupernik)
> wrote:
>
> >Yes another question ... I thank all that have taken to help me learn
these
> >new things.
> >
> >I want to display 10 records per page and allow the user to move on to
the
> >next page of new records. The code below allows me to move to the second
> >page of records but not any further. I can't seem to think what else
needs
> >to be added or modified to get this to function correctly. Any thoughts?
> >
> >Again, thanks in advance for any input.
> >
> >Code:
> >
> >if ($execute || $nextpg) {
> >
> > if ($person == "-" && !$nextpg) {
> >
> > $error = "Please select your name!";
> >
> > } elseif ($magicword != "pw" && !$nextpg) {
> >
> > $error = "Please enter correct password!";
> >
> > } else {
> >
> > $execute = "good";
> >
> > $db =
> > mysql_connect("localhost","username","pw");
> >
> > mysql_select_db("countryloft");
> >
> > if (!$nextpg) {
> >
> > $i = 0;
> >
> > } else {
> >
> > $i = $i+10;
> >
> > }
> >
> > // count number of new requests
> > $resource = mysql_query("SELECT COUNT(*) cnt FROM
> >catalogs WHERE PROCESSED IS NULL");
> >
> > $countreq = mysql_fetch_array($resource);
> >
> > // get requests from table
> > $result = mysql_query("SELECT * FROM catalogs
WHERE
> >PROCESSED IS NULL LIMIT $i,10");
> >
> > if (!$nextpg) {
> >
> > echo "Total Requests: $countreq[cnt]\n";
> >
> > }
> >
> > echo "<table border=1 width=700>\n";
> >
> > echo
>
>"<tr><td></td><td><u><b>Name</b></u></td><td><u><b>Address</b></u></td><td>
<
>
> >u>>u><b>City</b></u></td><td><u><b>State</b></u></td><td><u><b>Zip
>
>Code</b></u></td><td><u><b>Country</b></u></td><td><u><b>E-Mail</b></u></td
>
> ></tr>\n";
> >
> > $reqcount = 0;
> >
> > while ($myrow = mysql_fetch_row($result)) {
> >
> > $reqcount = $reqcount+1;
> >
> > printf("<tr><td
> >bgcolor=\"#FFFF99\">$reqcount<td>%s
>
>%s</td><td>%s<br>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s<
/
> >td></tr>\n",
> >
>
>$myrow[0],$myrow[1],$myrow[2],$myrow[3],$myrow[4],$myrow[6],$myrow[5],$myro
w
> >[7],$myrow[8]);
> >
> > }
> >
> > echo "</table>\n";
> >
> > echo "<br><a
> > href=\"$PHP_SELF?nextpg=good?i=$i\">Next
> >Page</a>\n";
> >
> >
> > }
> >
> > }
> >
>