473,396 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

php mysql form variable works one time

Hello,

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?

LouB.

=================================
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());

Nov 22 '06 #1
4 1369

ba******@gmail.com wrote:
Hello,

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?

LouB.
something tells me you have a "click here to see rows 9-16" type link?
are you passing you var in the link?

Nov 22 '06 #2
Yes I have links printed at the end of the first page for viewing
additional rows/page.
I did not believe I need to pass the vaiable. If needed how do I do
that?

Lou

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
}
else
{
$nav .= " <a href=\"$self?page=$page\">$page</a";
}
}

print "$nav";

================================================== ===

ba******@gmail.com wrote:
Hello,

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?

LouB.

=================================
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());
Nov 22 '06 #3
Thanks for the help. It was a issue where I was not passing the
secound var in the link. I corrected the problem with the following:

$nav .= " <a href=\"$self?page=$page&sortby1=$sortby\">$page</a";

BKDotCom wrote:
ba******@gmail.com wrote:
Hello,

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?

LouB.

something tells me you have a "click here to see rows 9-16" type link?
are you passing you var in the link?
Nov 22 '06 #4
Thats very insecure script.

Have a look at: mysql_real_escape(), is_number(), isset()

Nov 24 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex | last post by:
This may sound like a simple question but I really dont' know how to do this. I know you can call a Form Variable in a VBscript using Request.Form("FieldName") and make equal a local variable...
7
by: NetCoder | last post by:
Hi to all, I have made a script that uses both JavaScript and PHP. The script has a form and when it is submitted, a JavaScript confirmation box appears, asking the user to confirm their action....
10
by: yawnmoth | last post by:
i've written some javascript code that i believe should set a form variable to a certain value, depending on what the user clicks on. unfortunately, it isn't working. here's the url: ...
2
by: bebelino | last post by:
Hello, this should be an easy one, but I've had always troubles with it. How to pass trough a querydef-variable, form-variable and so on from a function to the caller-routine? Is there a simply...
5
by: Diego Pino | last post by:
Hello, I am experience some problems reading a form variable from a Javascript function. The point with this particular variable is that its name has the following syntax: <input...
8
by: tnspc | last post by:
I'm trying to access a Request.Form variable and plug it into an SQL statement, so that the statement will select just the particular data I need. Here's the offending snippet of code: sql =...
5
by: emajka21 | last post by:
I am trying to create a database that saves marathon times to a database. The way the times are marked are in minutes and seconds. There are 8 sections to the marathon and the times will have to be...
6
by: Steve JORDI | last post by:
Hi, is there a way to read the content of a form variable before a POST? I have a form with a "duplicate" button which opens a new form with most of the fields filled with the values of the...
5
by: RacerX2000 | last post by:
I have an MS access Database (2000) and Have created a form that sets a variable to a value I would like (Based on other selections in the form) to pass to my query criteria and I get the following...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.