What I'm trying to do here is use a <select name=> option, use
the variable that is selected and open a table, paginated
ofcourse. It will return the first page but it won't let me view any
of the other pages. I'm not 100% but I'm pretty sure that the variable
is being cleared when selecting a new page.
So here I'm setting up the option and pulling the options from a mysqldb.
$begin = 1;
echo "<table>";
echo "<tr>";
echo "<td><select name=\"f_name\">";
echo "<option value=\"\">Select Filter</option>";
$select = "SELECT * FROM filters";
$select1 = mysql_query($select);
$select3 = mysql_num_rows($select1);
while ($begin <= $select3) {
$checkexist = "SELECT * FROM filters WHERE fid = '$begin'";
$checkresult = mysql_query($checkexist);
$checkarray = mysql_fetch_array($checkresult);
$filter_name = $checkarray["filter_name"];
if (empty($filter_name)) {
echo "</select>";
}else {
echo "<option value=\"$filter_name\">$filter_name</option>";
}
$begin ++;
}
echo "</select>";
echo "</td></tr></table>";
$filter = mysql_query("SELECT * FROM filters WHERE filter_name='$f_name'");
$filter1 = mysql_fetch_array($filter);
//this is the variable I want to pass and hold
$filter2 = $filter1["filter"];
?>
<center>
<br><br>
<input type="Submit" name="submit" value="Report"></center>
This is the mysql select/paginate script ... where the variable $filter2 is used in the initial instance but for the additional pages
<?php
$limit=30;
$res1 = mysql_query("SELECT * FROM records WHERE ".$filter2."ORDER BY records.date ASC",$db);
$numrows=mysql_num_rows($res1);
if (empty($offset)) {
$offset=0;
}
?>
<br><br>
<table border="2">
<tr><td>Date:</td><td>Time:</td><td>Chronological:</td><td>Call Type:</td><td>Extension:</td><td>Line:</td><td>Digits:</td><td>Account:</td></tr>
<?php
$res = mysql_query("SELECT date, time, duration, type, extension, line, digits FROM records WHERE ".$filter2." ORDER BY records.date, records.time ASC limit $offset, $limit", $db);
if ($myrow = mysql_fetch_array($res)) {
do {
printf("<tr><td><b>%s </b></td><td><b>%s </b></td><td><b>%s </b></td><td><b>%s </b></td><td><b>%s </b></td><td><b>%s </b></td><td><b>%s </b></td><td><b>%s </b></td></tr>\n", $myrow["date"], $myrow["time"], $myrow["duration"], $myrow["type"], $myrow["extension"], $myrow["line"], $myrow["digits"], $myrow["account"]);
}
while ($myrow = mysql_fetch_array($res));
echo "</table>\n";
echo "<br><a href='welcome.php'>Back to Main</a><br>\n";
echo $_SERVER["HTTP_USER_AGENT"];
echo "<br>";
if ($offset >= $limit) { // bypass PREV link if offset is 0
$prevoffset=$offset - $limit;
print "<a href=\"$PHP_SELF?offset=$prevoffset\">PREV</a> \n";
}
$pages=intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
for ($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a> \n";
}
if (!( ( ($offset+$limit) / $limit) >= $pages) && $pages!=1) {
$newoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?offset=$newoffset\">NEXT</a></td></tr>";
}
include('footer.inc');
} else {
echo "Sorry, no records were found!";
}
?>
The first page comes up without a hitch but when I select any
of the other pages (ie. 1 or 2 or 3 or even NEXT), it returns
a ""Warning: mysql_num_rows(): supplied argument is not a
valid MySQL result resource in ..."" and ""Warning:
mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in..."" Not sure how to carry the variable when
selecting a new page.
Any help would be greatly appreciated.
Thanx is advance ... Jaybroni.