PDA

View Full Version : Variable value for form text...



Stevens
10-14-2003, 02:34 PM
Folks,

Is there any way that I can assign a link to hold value with or putting it into a form so all my users have to do is click on a link and the receiving php script will process the link in itself ($_SERVER('$_SELF')) as a variable? I don't want to require user input, bar the click on the link, in order to perform a search...

ERIC

Chris
10-14-2003, 03:58 PM
Its called a query string.

http://www.example.com/script.php?variable=whatever&variable2=whatever

For methods on taming query strings see here:

http://www.websitepublisher.net/article/search_engine_friendly_urls/

Stevens
10-15-2003, 07:31 AM
OK, now that really helped me out a ton, but I need to do the same thing when processing a form. What I need to do now is to have the user submit search criteria info into a text box, but when information appears I need it to list ordered by criteria first then barcode. This is the end of my conditional.

else {
$mod = $_POST['model'];
}

$query = "SELECT barcode, serial_number, location, manufacturer, model, item, item_type FROM invtemp WHERE model LIKE '%$mod%' ORDER BY barcode";

$result = mssql_query( $query );

Along with a "model" search, I have 3 other forms on my search page. I can do this pretty easily using 4 different scripts, but that defeats the purpose. Is there a way that I can append a variable for "model" in this case when submitting via a form? I'd like it to read,

else {

$var = $criteria

$var2 = $_POST['$var'];
}

$query = "SELECT barcode, serial_number, location, manufacturer, model, item, item_type FROM invtemp WHERE $var LIKE '%$var2%' ORDER BY $var, barcode";

$result = mssql_query( $query );

...to make it more generic, but I'm not sure how to define $criteria as "model"...or "item" or "location" or whatever the case...I need it to be done when the form is submitted. Any ideas?

ERIC

Stevens
10-15-2003, 01:22 PM
OK, I'm an idiot...all I had to do was include the query string on my action link!

K, next...if anyone cares...

I am returning data to be displayed by rows. Each row returned has an identifier (barcode). I need to be able to have the users click on the identifier of each returned row that will bring up editible properties of the selected row. I need to know how to manipulate the variables in this case to put hyperlinks on each returned object in my "barcode" field. Anyone?

Chris
10-15-2003, 02:58 PM
What is your primary key?

A link like:

<a href = "edit.php?id=primarykey">

usually works.