Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- php mysql form variable works one time
November 22, 2006, 2:28 pm
rate this thread
I have a form the post to a php script, the variable is passed to the
php script successfully. I then query MySQL and output 8 rows at a
time. So the problem I'm having is the first 8 rows are displayed on
the web page correctly, but now when I attempt to display rows 9-16
the variable that was posted from the form is now blank. How do I
ensure the variable does not disappear?
Here are the three main part of my php script.
# post from form....
$sortby = $_REQUEST["sortby"];
$query = "select personal_identifier, first_name, last_name,
company_name, photo_path, custom_field_1 from $dbname order by $sortby
limit $offset, $rowsPerPage";
result = mysql_query ($query)
//or die ("Cannot execute query");
or die (mysql_error());
Re: php mysql form variable works one time
Yes I have links printed at the end of the first page for viewing
I did not believe I need to pass the vaiable. If needed how do I do
Here is the code for links at end og page.
# print number of pages available at bottom of the web page
// how many rows we have in database
$query = "SELECT COUNT(*) AS numrows FROM $dbname";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
if ($page == $pageNum)
$nav .= " $page "; // no need to create a link to current page
$nav .= " <a href=\"$self?page=$page\">$page</a> ";