Help with browsing db

This is a discussion on Help with browsing db within the PHP Language forums, part of the PHP Programming Forums category; Need some opinions on how best to display in excess of 14K records based on users search criteria. Application Concept: ----------------------- [...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-19-2004
redneck_kiwi
 
Posts: n/a
Default Help with browsing db

Need some opinions on how best to display in excess of 14K records
based on users search criteria.

Application Concept:
-----------------------

[1] User enters various search criteria (as many as 13 different
fields) AND can select 2 fields to sort on.
[2] User can also limit the results displayed per page
[3] Once the user presses "Submit", the SQL string is built and the DB
is queried.
[4] Results are displayed to the user, x records per page with "Next
<<->> Previous" link under results. If user
did not choose a limit, I limit to 20 records per page.
[5] Clicking on the Next or Previous links walks the user through the
data.


Application Logic
-----------------------

PHP Code:

if($submit) {
// Code to display results etc
} else {
// Code to gather search criteria

Sounds simple, right? Basically it is, however I am attempting to do
something here I have never done before. In other
applications I have developed, I have only used the Next - Previous
link idea when I have simply pulled the entire database
so that the user could browse the db. This time though I need to allow
the user to set parameters before browsing.

Here's my problem from a code perspective:

PHP Code:
<?
if($start OR $submit) {
if(!isset(
$start)) $start 0;

// First step, let's connect to the DB and then build the SQL
string

$db 
mysql_connect("host""user""password") or die("Could
not connect to db: "
mysql_error());
mysql_select_db("dbname",$db);

// Our various search terms from from the initial form. Let's
build the SQL string we are going to use

// First, change the cost figures to something SQL will
recognize.

$val1=dollarval($dolval=$AYVAL);$val2=dollarval($dolval=$BYVAL);
$val3=dollarval($dolval=$EYVAL);$val4=dollarval($dolval=$Y4VAL);

// Set up to use wildcards by default if the user chooses
nothing for the field
if(!$fsc$fsc='%';if(!$niin$niin='%';if(!$mmac)
$mmac='%';if(!$ims$ims='%';if(!$smc$smc='%';
if(!
$PMS_BUYER$PMS_BUYER='%';if(!$PMS_SELLER)
$PMS_SELLER='%';


$sql="SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
'$bpc' AND FSC LIKE '$fsc' AND NIIN LIKE '$niin'
AND SGM_MMAC LIKE '$mmac' AND IMS LIKE '$ims' AND SMC LIKE
'$smc' AND PMS_BUYER LIKE '$PMS_BUYER' AND
PMS_SELLER LIKE '$PMS_SELLER' AND AY_VAL_ACT_ROLLUP $val1 AND
BY_VAL_ACT_ROLLUP $val2 AND EY_VAL_ACT_ROLLUP
$val3 AND Y4_VAL_ACT_ROLLUP $val4 ORDER BY $orderby1,$orderby2
LIMIT $start, 20"
;
$result=mysql_query($sql,$db);

// get the count of the number of rows of data
$query "SELECT count(*) as count FROM Repair";
$res mysql_query($query);
$row mysql_fetch_array($res);
$numrows $row['count'];

$result mysql_query($sql);

echo 
$sql;
echo 
"<CENTER>There are " $numrows " records</CENTER>";

// Now, switch to HTML for easier coding
?>
<TABLE BORDER=2 CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>
<COL><COL><COL><COL><COL>
<TBODY>
<TR>
<TD>ALC</TD>
<TD>FSC</TD>
<TD>NIIN</TD>
<TD>MMAC</TD>
<TD>Noun</TD>
<TD>First Year Qty</TD>
<TD>Options</TD>
</TR>
<?
while($myrow=mysql_fetch_array($result)) {
echo 
"<TR>";
echo 
"<TD
CLASS=data>"
.$myrow["ALC"]."</TD>";
echo 
"<TD
CLASS=data>"
.$myrow["FSC"]."</TD>";
echo 
"<TD
CLASS=data>"
.$myrow["NIIN"]."</TD>";
echo 
"<TD
CLASS=data>"
.$myrow["SGM_MMAC"]."</TD>";
echo 
"<TD
CLASS=data>"
.$myrow["NOUN"]."</TD>";
echo 
"<TD
CLASS=data>"
.$myrow["AY_QTY_ACT_ROLLUP"]."</TD>";
echo 
"<TD CLASS=data><a TARGET=_BLANK
href=viewrep.php?id="
.$myrow["ID"].">View</a></TD>";
echo 
"</TR>";
}
?>
</TBODY>
</TABLE>
<?
if($start 0)
echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
(
$start 20) . "\">Previous</A></CENTER><BR>\n";
if(
$numrows > ($start 20))
echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
(
$start 20) . "\">Next</A></CENTER><BR>\n";

} else {

?>
User input code here
<TR><TD COLSPAN=5 ALIGN=center><INPUT TYPE="submit"
NAME="submit" VALUE="Find Data"></TD></TR>
</TBODY>
</TABLE>
My problem appears to be that my variables are not carrying over
whenever Next or Previous is clicked. Anybody have a suggestion as to
how I can get this to work?

TIA

rk

Reply With Quote
  #2 (permalink)  
Old 10-19-2004
Shawn Wilson
 
Posts: n/a
Default Re: Help with browsing db

Hi,

redneck_kiwi wrote:
>
> Need some opinions on how best to display in excess of 14K records
> based on users search criteria.
>
> Application Concept:
> -----------------------
>
> [1] User enters various search criteria (as many as 13 different
> fields) AND can select 2 fields to sort on.
> [2] User can also limit the results displayed per page
> [3] Once the user presses "Submit", the SQL string is built and the DB
> is queried.
> [4] Results are displayed to the user, x records per page with "Next
> <<->> Previous" link under results. If user
> did not choose a limit, I limit to 20 records per page.
> [5] Clicking on the Next or Previous links walks the user through the
> data.
>
> Application Logic
> -----------------------
>
>
PHP Code:
>
> if(
$submit) {
// Code to display results etc
> } else {
// Code to gather search criteria
> }
>

>
> Sounds simple, right? Basically it is, however I am attempting to do
> something here I have never done before. In other
> applications I have developed, I have only used the Next - Previous
> link idea when I have simply pulled the entire database
> so that the user could browse the db. This time though I need to allow
> the user to set parameters before browsing.
>
> Here's my problem from a code perspective:
>
>
PHP Code:
<?
> if($start OR $submit) {
> if(!isset(
$start)) $start 0;
>
// First step, let's connect to the DB and then build the SQL
string
>
$db mysql_connect("host""user""password") or die("Could
> not connect to db: "
mysql_error());
mysql_select_db("dbname",$db);
>
// Our various search terms from from the initial form. Let's
build the SQL string we are going to use
>
// First, change the cost figures to something SQL will
recognize.
>
$val1=dollarval($dolval=$AYVAL);$val2=dollarval($dolval=$BYVAL);
$val3=dollarval($dolval=$EYVAL);$val4=dollarval($dolval=$Y4VAL);
>
// Set up to use wildcards by default if the user chooses
nothing for the field
> if(!$fsc$fsc='%';if(!$niin$niin='%';if(!$mmac)
$mmac='%';if(!$ims$ims='%';if(!$smc$smc='%';
> if(!
$PMS_BUYER$PMS_BUYER='%';if(!$PMS_SELLER)
$PMS_SELLER='%';
>
$sql="SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
> '$bpc' AND FSC LIKE '$fsc' AND NIIN LIKE '$niin'
> AND SGM_MMAC LIKE '$mmac' AND IMS LIKE '$ims' AND SMC LIKE
> '$smc' AND PMS_BUYER LIKE '$PMS_BUYER' AND
> PMS_SELLER LIKE '$PMS_SELLER' AND AY_VAL_ACT_ROLLUP $val1 AND
> BY_VAL_ACT_ROLLUP $val2 AND EY_VAL_ACT_ROLLUP
> $val3 AND Y4_VAL_ACT_ROLLUP $val4 ORDER BY $orderby1,$orderby2
> LIMIT $start, 20"
;
$result=mysql_query($sql,$db);
>
// get the count of the number of rows of data
$query "SELECT count(*) as count FROM Repair";
$res mysql_query($query);
$row mysql_fetch_array($res);
$numrows $row['count'];
>
$result mysql_query($sql);
>
> echo 
$sql;
> echo 
"<CENTER>There are " $numrows " records</CENTER>";
>
// Now, switch to HTML for easier coding
?>
> <TABLE BORDER=2 CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>
> <COL><COL><COL><COL><COL>
> <TBODY>
> <TR>
> <TD>ALC</TD>
> <TD>FSC</TD>
> <TD>NIIN</TD>
> <TD>MMAC</TD>
> <TD>Noun</TD>
> <TD>First Year Qty</TD>
> <TD>Options</TD>
> </TR>
<?
> while($myrow=mysql_fetch_array($result)) {
> echo 
"<TR>";
> echo 
"<TD
> CLASS=data>"
.$myrow["ALC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["FSC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["NIIN"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["SGM_MMAC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["NOUN"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["AY_QTY_ACT_ROLLUP"]."</TD>";
> echo 
"<TD CLASS=data><a TARGET=_BLANK
> href=viewrep.php?id="
.$myrow["ID"].">View</a></TD>";
> echo 
"</TR>";
> }
?>
> </TBODY>
> </TABLE>
<?
> if($start 0)
> echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
> (
$start 20) . "\">Previous</A></CENTER><BR>\n";
> if(
$numrows > ($start 20))
> echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
> (
$start 20) . "\">Next</A></CENTER><BR>\n";
>
> } else {
>
?>
> User input code here
> <TR><TD COLSPAN=5 ALIGN=center><INPUT TYPE="submit"
> NAME="submit" VALUE="Find Data"></TD></TR>
> </TBODY>
> </TABLE>
>
>
>
> My problem appears to be that my variables are not carrying over
> whenever Next or Previous is clicked. Anybody have a suggestion as to
> how I can get this to work?


Hi,
I didn't actually read through all your code, but you should probably validate,
then set the validated variables as session variables. Then you can just use
the session variables as-is on any subsequent page and use them to build your
query.

Shawn

--
Shawn Wilson
shawn@glassgiant.com
http://www.glassgiant.com
Reply With Quote
  #3 (permalink)  
Old 10-19-2004
Shawn Wilson
 
Posts: n/a
Default Re: Help with browsing db

Hi,

redneck_kiwi wrote:
>
> Need some opinions on how best to display in excess of 14K records
> based on users search criteria.
>
> Application Concept:
> -----------------------
>
> [1] User enters various search criteria (as many as 13 different
> fields) AND can select 2 fields to sort on.
> [2] User can also limit the results displayed per page
> [3] Once the user presses "Submit", the SQL string is built and the DB
> is queried.
> [4] Results are displayed to the user, x records per page with "Next
> <<->> Previous" link under results. If user
> did not choose a limit, I limit to 20 records per page.
> [5] Clicking on the Next or Previous links walks the user through the
> data.
>
> Application Logic
> -----------------------
>
>
PHP Code:
>
> if(
$submit) {
// Code to display results etc
> } else {
// Code to gather search criteria
> }
>

>
> Sounds simple, right? Basically it is, however I am attempting to do
> something here I have never done before. In other
> applications I have developed, I have only used the Next - Previous
> link idea when I have simply pulled the entire database
> so that the user could browse the db. This time though I need to allow
> the user to set parameters before browsing.
>
> Here's my problem from a code perspective:
>
>
PHP Code:
<?
> if($start OR $submit) {
> if(!isset(
$start)) $start 0;
>
// First step, let's connect to the DB and then build the SQL
string
>
$db mysql_connect("host""user""password") or die("Could
> not connect to db: "
mysql_error());
mysql_select_db("dbname",$db);
>
// Our various search terms from from the initial form. Let's
build the SQL string we are going to use
>
// First, change the cost figures to something SQL will
recognize.
>
$val1=dollarval($dolval=$AYVAL);$val2=dollarval($dolval=$BYVAL);
$val3=dollarval($dolval=$EYVAL);$val4=dollarval($dolval=$Y4VAL);
>
// Set up to use wildcards by default if the user chooses
nothing for the field
> if(!$fsc$fsc='%';if(!$niin$niin='%';if(!$mmac)
$mmac='%';if(!$ims$ims='%';if(!$smc$smc='%';
> if(!
$PMS_BUYER$PMS_BUYER='%';if(!$PMS_SELLER)
$PMS_SELLER='%';
>
$sql="SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
> '$bpc' AND FSC LIKE '$fsc' AND NIIN LIKE '$niin'
> AND SGM_MMAC LIKE '$mmac' AND IMS LIKE '$ims' AND SMC LIKE
> '$smc' AND PMS_BUYER LIKE '$PMS_BUYER' AND
> PMS_SELLER LIKE '$PMS_SELLER' AND AY_VAL_ACT_ROLLUP $val1 AND
> BY_VAL_ACT_ROLLUP $val2 AND EY_VAL_ACT_ROLLUP
> $val3 AND Y4_VAL_ACT_ROLLUP $val4 ORDER BY $orderby1,$orderby2
> LIMIT $start, 20"
;
$result=mysql_query($sql,$db);
>
// get the count of the number of rows of data
$query "SELECT count(*) as count FROM Repair";
$res mysql_query($query);
$row mysql_fetch_array($res);
$numrows $row['count'];
>
$result mysql_query($sql);
>
> echo 
$sql;
> echo 
"<CENTER>There are " $numrows " records</CENTER>";
>
// Now, switch to HTML for easier coding
?>
> <TABLE BORDER=2 CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>
> <COL><COL><COL><COL><COL>
> <TBODY>
> <TR>
> <TD>ALC</TD>
> <TD>FSC</TD>
> <TD>NIIN</TD>
> <TD>MMAC</TD>
> <TD>Noun</TD>
> <TD>First Year Qty</TD>
> <TD>Options</TD>
> </TR>
<?
> while($myrow=mysql_fetch_array($result)) {
> echo 
"<TR>";
> echo 
"<TD
> CLASS=data>"
.$myrow["ALC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["FSC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["NIIN"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["SGM_MMAC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["NOUN"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["AY_QTY_ACT_ROLLUP"]."</TD>";
> echo 
"<TD CLASS=data><a TARGET=_BLANK
> href=viewrep.php?id="
.$myrow["ID"].">View</a></TD>";
> echo 
"</TR>";
> }
?>
> </TBODY>
> </TABLE>
<?
> if($start 0)
> echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
> (
$start 20) . "\">Previous</A></CENTER><BR>\n";
> if(
$numrows > ($start 20))
> echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
> (
$start 20) . "\">Next</A></CENTER><BR>\n";
>
> } else {
>
?>
> User input code here
> <TR><TD COLSPAN=5 ALIGN=center><INPUT TYPE="submit"
> NAME="submit" VALUE="Find Data"></TD></TR>
> </TBODY>
> </TABLE>
>
>
>
> My problem appears to be that my variables are not carrying over
> whenever Next or Previous is clicked. Anybody have a suggestion as to
> how I can get this to work?


Hi,
I didn't actually read through all your code, but you should probably validate,
then set the validated variables as session variables. Then you can just use
the session variables as-is on any subsequent page and use them to build your
query.

Shawn

--
Shawn Wilson
shawn@glassgiant.com
http://www.glassgiant.com
Reply With Quote
  #4 (permalink)  
Old 10-19-2004
redneck_kiwi
 
Posts: n/a
Default Re: Help with browsing db

I took your suggestion to use session variables and it "almost"
works....

$_SESSION["sqlqry"]="SELECT * FROM Repair WHERE ALC LIKE '%' AND BP
LIKE '$bpc' AND FSC LIKE '$fsc' AND NIIN LIKE '$niin' AND SGM_MMAC LIKE
'$mmac' AND IMS LIKE '$ims' AND SMC LIKE '$smc' AND PMS_BUYER LIKE
'$PMS_BUYER' AND PMS_SELLER LIKE '$PMS_SELLER' AND Y_VAL_ACT_ROLLUP
$val1 AND BY_VAL_ACT_ROLLUP $val2 AND EY_VAL_ACT_ROLLUP
$val3 AND Y4_VAL_ACT_ROLLUP $val4 ORDER BY '$orderby1','$orderby2'
LIMIT"

For whatever reason, the '$orderby1' and '$orderby2' variables are not
carrying through. What am I doing wrong?

Reply With Quote
  #5 (permalink)  
Old 10-20-2004
Pedro Graca
 
Posts: n/a
Default Re: Help with browsing db

redneck_kiwi wrote:
> I took your suggestion to use session variables and it "almost"
> works....


[reformatted]

$_SESSION["sqlqry"] = "
SELECT *

FROM Repair

WHERE ALC LIKE '%'
AND BP LIKE '$bpc'
AND FSC LIKE '$fsc'
AND NIIN LIKE '$niin'
AND SGM_MMAC LIKE '$mmac'
AND IMS LIKE '$ims'
AND SMC LIKE '$smc'
AND PMS_BUYER LIKE '$PMS_BUYER'
AND PMS_SELLER LIKE '$PMS_SELLER'
AND Y_VAL_ACT_ROLLUP $val1 <== isn't there
AND BY_VAL_ACT_ROLLUP $val2 <== something
AND EY_VAL_ACT_ROLLUP $val3 <== missing
AND Y4_VAL_ACT_ROLLUP $val4 <== around here?

ORDER BY '$orderby1','$orderby2'

LIMIT <== and here?
"

> For whatever reason, the '$orderby1' and '$orderby2' variables are not
> carrying through. What am I doing wrong?


1. try verifying the contents your session array:

<?php
echo '<pre>$_SESSION array:<br>';
print_r($_SESSION);
echo '<br></pre>';
?>



2. And I'd not use globals, nor copy the session to 'normal' variables;
but instead I'd use the session array directly to build the query:

<?php
/* AFAICT there's no need to put the query in the session array */
$sqlqry = <<<SQL_QUERY
SELECT column1, col2, col18, col7, ...

FROM Repair

WHERE ALC LIKE '%'
AND BP LIKE '$_SESSION[bpc]'
AND ...

...

ORDER BY '$_SESSION[orderby1]', '$_SESSION[orderby2]'

LIMIT ...
SQL_QUERY;
?>



3. Also try to see if you're using undeclared variables, by putting

<?php error_reporting(E_ALL); ?>

at the very top of your scripts.



Happy Coding :-)
--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
Reply With Quote
  #6 (permalink)  
Old 10-20-2004
Tony Marston
 
Posts: n/a
Default Re: Help with browsing db

If you want help with pagination take a look at
http://www.tonymarston.co.uk/php-mysql/pagination.html

--
Tony Marston

http://www.tonymarston.net



"redneck_kiwi" <kf4pfw@gmail.com> wrote in message
news:1098209405.802702.235840@f14g2000cwb.googlegr oups.com...
> Need some opinions on how best to display in excess of 14K records
> based on users search criteria.
>
> Application Concept:
> -----------------------
>
> [1] User enters various search criteria (as many as 13 different
> fields) AND can select 2 fields to sort on.
> [2] User can also limit the results displayed per page
> [3] Once the user presses "Submit", the SQL string is built and the DB
> is queried.
> [4] Results are displayed to the user, x records per page with "Next
> <<->> Previous" link under results. If user
> did not choose a limit, I limit to 20 records per page.
> [5] Clicking on the Next or Previous links walks the user through the
> data.
>
>
> Application Logic
> -----------------------
>
>
PHP Code:
>
> if(
$submit) {
// Code to display results etc
> } else {
// Code to gather search criteria
> }
>

>
> Sounds simple, right? Basically it is, however I am attempting to do
> something here I have never done before. In other
> applications I have developed, I have only used the Next - Previous
> link idea when I have simply pulled the entire database
> so that the user could browse the db. This time though I need to allow
> the user to set parameters before browsing.
>
> Here's my problem from a code perspective:
>
>
PHP Code:
<?
> if($start OR $submit) {
> if(!isset(
$start)) $start 0;
>
// First step, let's connect to the DB and then build the SQL
string
>
$db mysql_connect("host""user""password") or die("Could
> not connect to db: "
mysql_error());
mysql_select_db("dbname",$db);
>
// Our various search terms from from the initial form. Let's
build the SQL string we are going to use
>
// First, change the cost figures to something SQL will
recognize.
>
$val1=dollarval($dolval=$AYVAL);$val2=dollarval($dolval=$BYVAL);
$val3=dollarval($dolval=$EYVAL);$val4=dollarval($dolval=$Y4VAL);
>
// Set up to use wildcards by default if the user chooses
nothing for the field
> if(!$fsc$fsc='%';if(!$niin$niin='%';if(!$mmac)
$mmac='%';if(!$ims$ims='%';if(!$smc$smc='%';
> if(!
$PMS_BUYER$PMS_BUYER='%';if(!$PMS_SELLER)
$PMS_SELLER='%';
>
>
$sql="SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
> '$bpc' AND FSC LIKE '$fsc' AND NIIN LIKE '$niin'
> AND SGM_MMAC LIKE '$mmac' AND IMS LIKE '$ims' AND SMC LIKE
> '$smc' AND PMS_BUYER LIKE '$PMS_BUYER' AND
> PMS_SELLER LIKE '$PMS_SELLER' AND AY_VAL_ACT_ROLLUP $val1 AND
> BY_VAL_ACT_ROLLUP $val2 AND EY_VAL_ACT_ROLLUP
> $val3 AND Y4_VAL_ACT_ROLLUP $val4 ORDER BY $orderby1,$orderby2
> LIMIT $start, 20"
;
$result=mysql_query($sql,$db);
>
// get the count of the number of rows of data
$query "SELECT count(*) as count FROM Repair";
$res mysql_query($query);
$row mysql_fetch_array($res);
$numrows $row['count'];
>
$result mysql_query($sql);
>
> echo 
$sql;
> echo 
"<CENTER>There are " $numrows " records</CENTER>";
>
// Now, switch to HTML for easier coding
?>
> <TABLE BORDER=2 CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>
> <COL><COL><COL><COL><COL>
> <TBODY>
> <TR>
> <TD>ALC</TD>
> <TD>FSC</TD>
> <TD>NIIN</TD>
> <TD>MMAC</TD>
> <TD>Noun</TD>
> <TD>First Year Qty</TD>
> <TD>Options</TD>
> </TR>
<?
> while($myrow=mysql_fetch_array($result)) {
> echo 
"<TR>";
> echo 
"<TD
> CLASS=data>"
.$myrow["ALC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["FSC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["NIIN"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["SGM_MMAC"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["NOUN"]."</TD>";
> echo 
"<TD
> CLASS=data>"
.$myrow["AY_QTY_ACT_ROLLUP"]."</TD>";
> echo 
"<TD CLASS=data><a TARGET=_BLANK
> href=viewrep.php?id="
.$myrow["ID"].">View</a></TD>";
> echo 
"</TR>";
> }
?>
> </TBODY>
> </TABLE>
<?
> if($start 0)
> echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
> (
$start 20) . "\">Previous</A></CENTER><BR>\n";
> if(
$numrows > ($start 20))
> echo 
"<CENTER><A HREF=\"" $PHP_SELF "?start=" .
> (
$start 20) . "\">Next</A></CENTER><BR>\n";
>
> } else {
>
?>
> User input code here
> <TR><TD COLSPAN=5 ALIGN=center><INPUT TYPE="submit"
> NAME="submit" VALUE="Find Data"></TD></TR>
> </TBODY>
> </TABLE>
>
>
>
>
>
> My problem appears to be that my variables are not carrying over
> whenever Next or Previous is clicked. Anybody have a suggestion as to
> how I can get this to work?
>
> TIA
>
> rk
>



Reply With Quote
  #7 (permalink)  
Old 10-20-2004
redneck_kiwi
 
Posts: n/a
Default Re: Help with browsing db

Taking some of your suggestions I get the following results:

[1] Verifying the contents of the session array:

First pass:
$_SESSION array: Array
(
[sqlqry] => SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
'15' AND FSC LIKE '%' AND NIIN LIKE '%'
AND SGM_MMAC LIKE '%' AND IMS LIKE '%' AND SMC LIKE '%' AND PMS_BUYER
LIKE '%' AND
PMS_SELLER LIKE '%' AND AY_VAL_ACT_ROLLUP LIKE '%' AND
BY_VAL_ACT_ROLLUP LIKE '%' AND EY_VAL_ACT_ROLLUP
LIKE '%' AND Y4_VAL_ACT_ROLLUP LIKE '%' ORDER BY 'FSC','FSC' LIMIT

As you can see, all the variables are set as expected. Clicking the
next (for the next 20 items):

$_SESSION array: Array
(
[sqlqry] => SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
'15' AND FSC LIKE '%' AND NIIN LIKE '%'
AND SGM_MMAC LIKE '%' AND IMS LIKE '%' AND SMC LIKE '%' AND PMS_BUYER
LIKE '%' AND
PMS_SELLER LIKE '%' AND AY_VAL_ACT_ROLLUP LIKE '%' AND
BY_VAL_ACT_ROLLUP LIKE '%' AND EY_VAL_ACT_ROLLUP
LIKE '%' AND Y4_VAL_ACT_ROLLUP LIKE '%' ORDER BY '','' LIMIT

As you can see, the two fields to order by are being dropped. Is there
a limit to the size of the array here? The reason for the LIMIT being
blank is that those values are dynamic and are added when I build the
actual sql string.

I am going to try using the individual session elements once I figure
out what the heck is going on with those order by elements.

Thanks

rk

Reply With Quote
  #8 (permalink)  
Old 10-20-2004
Shawn Wilson
 
Posts: n/a
Default Re: Help with browsing db

redneck_kiwi wrote:
>
> Taking some of your suggestions I get the following results:
>
> [1] Verifying the contents of the session array:
>
> First pass:
> $_SESSION array: Array
> (
> [sqlqry] => SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
> '15' AND FSC LIKE '%' AND NIIN LIKE '%'
> AND SGM_MMAC LIKE '%' AND IMS LIKE '%' AND SMC LIKE '%' AND PMS_BUYER
> LIKE '%' AND
> PMS_SELLER LIKE '%' AND AY_VAL_ACT_ROLLUP LIKE '%' AND
> BY_VAL_ACT_ROLLUP LIKE '%' AND EY_VAL_ACT_ROLLUP
> LIKE '%' AND Y4_VAL_ACT_ROLLUP LIKE '%' ORDER BY 'FSC','FSC' LIMIT
>
> As you can see, all the variables are set as expected. Clicking the
> next (for the next 20 items):
>
> $_SESSION array: Array
> (
> [sqlqry] => SELECT * FROM Repair WHERE ALC LIKE '%' AND BP LIKE
> '15' AND FSC LIKE '%' AND NIIN LIKE '%'
> AND SGM_MMAC LIKE '%' AND IMS LIKE '%' AND SMC LIKE '%' AND PMS_BUYER
> LIKE '%' AND
> PMS_SELLER LIKE '%' AND AY_VAL_ACT_ROLLUP LIKE '%' AND
> BY_VAL_ACT_ROLLUP LIKE '%' AND EY_VAL_ACT_ROLLUP
> LIKE '%' AND Y4_VAL_ACT_ROLLUP LIKE '%' ORDER BY '','' LIMIT
>
> As you can see, the two fields to order by are being dropped. Is there
> a limit to the size of the array here? The reason for the LIMIT being
> blank is that those values are dynamic and are added when I build the
> actual sql string.
>
> I am going to try using the individual session elements once I figure
> out what the heck is going on with those order by elements.


I'm not sure what the limit is (if any) on session variables, but yo