Hello, I'm writing a small database querying applet in PHP for a project at my school. The problem is, I can't quite figure some of the code out, since most of it was written by another student with poor commenting... Anyhow, Heres the problem:When the web page that has the results from this file is created, it creates links that allow you to look at just 10 of the returns from the query or so, then it creates a link to the next 10 and so on. The problem is it doesn't go to the next 10 or so when I click on the link. Its not transferring a var called pgindex after its changed. Anyhow, anyone have any ideas???
here is my code so you can peruse it, and please email me if you can help! Thanks!
Chris Madson


//start code
<html>
<body>

<?php

include("queryclass.phtml");

$basis1="SELECT sublist.ln, sublist.copies, sublist.name, sublist.sex, sublist.inst, place.place, category.category, sublist.rang, sublist.klass FROM sublist, place, category WHERE (place.place_id=sublist.place_id) AND (category.category_id=sublist.category_id) AND ";

$asdf = new query();


$asdf->add($individual, "name LIKE "%$individual%"");
$asdf->add($gender, "sex="$gender"");
$asdf->add($institution, "inst LIKE "%$institution%"");

//category stuff

if($Aristocracy=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Aristocracy"");
}
else
{
$asdf->add($Aristocracy, "sublist.category_id="$Aristocracy"");
}


if($Provincial=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Provincial"");
}
else
{
$asdf->add($Provincial, "sublist.category_id="$Provincial"");
}

if($Military=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Military"");
}
else
{
$asdf->add($Military, "sublist.category_id="$Military"");
}

if($COfficials=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Civil Officials"");
}
else
{
$asdf->add($COfficials, "sublist.category_id="$COfficials"");
}

if($ONobles=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Other Nobles (Sphere Unclear)"");
}
else
{
$asdf->add($ONobles, "sublist.category_id="$ONobles"");
}

if($Professionals=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Professionals"");
}
else
{
$asdf->add($Professionals, "sublist.category_id="$Professionals"");
}

if($Merchants=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Merchants"");
}
else
{
$asdf->add($Merchants, "sublist.category_id="$Merchants"");
}

if($OCategories=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Other Categories"");
}
else
{
$asdf->add($OCategories, "sublist.category_id="$OCategories"");
}

if($Category=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Category Unspecified"");
}
else
{
$asdf->add($Category, "sublist.category_id="$Category"");
}

if($Institutions=="all")
{
$asdf->add("true", "sublist.category_id=category.category_id");
$asdf->add("true", "category.category_type="Institutions"");
}
else
{
$asdf->add($Institutions, "sublist.category_id="$Institutions"");
}

if($place!="")
{
$asdf->add(1,"place.place LIKE "$place%"");

}
else
{

for($n=1;$n<=4;$n++)
{
if(${"place_id" . $n})
{
$asdf->add(1, "sublist.place_id="" . ${"place_id" . $n} . """);
}
}
}


//now that we have the query, we connect to the almighty DB.

$host="beaker.lib.umn.edu";
$user="harmless";
$pass="r34d0nly";
$base="sublist";

$my_cn=mysql_connect($host, $user, $pass);

if($my_cn==0)
{
print "Unable to connect to the database at host $host. Please try again later.";
print "</body></html>";
exit;
}


$stat=mysql_select_db($base, $my_cn);

if(!$stat)
{
print "Unable to use the database $base. Try connecting later.";
print "</body></html>";
exit;
}

//end connect stuff

//find out how many results are involved
$asdf->change_basis("SELECT count(sublist.rn) AS blah FROM sublist, place, category WHERE (place.place_id=sublist.place_id) AND (category.category_id=sublist.category_id) AND ");
$res=mysql_query($asdf->compose());
$row=mysql_fetch_array($res);
$numres=$row[blah];

//set up what page we are on

if($pgindex=="")
{
$pgindex=0;
}

$asdf->add_tail("LIMIT $pgindex, $resppg");


//Get the acutal data

$asdf->change_basis($basis1); //basis1 is at the top
$res=mysql_query($asdf->compose());

print "<h2>Results " . (1+$pgindex) ."-";

if(($pgindex+$resppg)<$numres)
{
print ($pgindex+$resppg);
}
else
{
print $numres;
}
print " of " . $numres . " results</h2>";


print "<table bgcolor="#d0d0e0"><tr><td><table border="2">";
print "<tr><td><b>Name</b></td><td><b>Gender</b></td><td><b>Institution</b></td><td><b>LN</b& gt;</td><td><b>Copies</b></td><td><b>Category</b></td><td><b>Place</b></td><td><b>Klass&lt ;/b></td><td><b>Rang</b></td></tr>";


while($row=mysql_fetch_array($res))
{
print "<tr><td>$row[name]</td><td>$row[sex]</td><td>$row[inst]</td><td>$row[ln]</td><td>$row[copies]</td><td>$row[ category]</td><td>$row[place]</td><td>$row[klass]</td><td>$row[rang]</td></tr>";
}
print "</table></td></td></table><br />";

//next page

$next=$pgindex+$resppg;


if($next<$numres)
{
$next_link=ereg_replace("pgindex=$pgindex", "&pgindex=$next", $QUERY_STRING);

print "<a href="list.phtml?$next_link">Next Page</a>&nbsp;&nbsp;&nbsp;";

}


//previous page
if($pgindex>0)
{
$back=$pgindex-$resppg;
$back_link=ereg_replace("pgindex=$pgindex", "&pgindex=$back", $QUERY_STRING);

print "<a href="list.phtml?$back_link">Previous Page</a>";
}

print "<br /><a href="index.phtml">New Search</a><br />";
?>

//end of code