Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Large Number Of Variables, Is This Possible?

Status
Not open for further replies.

HowdeeDoodee

Technical User
Mar 14, 2005
61
US
This is my first post. I have a number of spreadsheets in Excell I will be converting to csv to then input into a MySql db using phpMyAdmin. Every record in the MySql db has a field called References with index names and numbers. Some records in the db have over sixty of these index names and numbers in the References field. An example of the index names and numbers would be ---

cat 122:111 ; dog 1000:222 ; foster 1111; tween 1:001

Is there any way to hyperlink from the cell containing these index names and numbers to a table called References so when the user clicks on a hyperlink in the initial results page showing these values in a cell, all the matching records in the References table with any of these index names and numbers shows up on a second results page? I know I can call up a results page by passing individual values using a hyperlink. What I do not know is how to pull up many records on a results page using 50 or 60 variables like the ones above at one time. Do I need to create some kind of index file containing a duplicate of the names and numbers so when records in the index file are called up all of the associated names and numbers pull records to appear on the results page or is there another way?

To be more specific and to try to explain this more fully...I have two tables, a table name FirstRetrieval and a table names References.

In the table called References, each record in the table contains one or more names and index numbers. I want to access the References table by using a hyperlink on a results page from the FirstRetrieval table. There can be 50, 60, or more names and index numbers appearing in the results page from a first data retrieval action by a user when the user accessing the First Retrieval table. I want the user to be able to click on a "See These" link in the names and index cell of the First Retrieval table results page so all of the corresponding records from the References table will be retrieved. My problem is I do not know how to, or even if I can, embed many of the index names and numbers in an html search string.

Thank you in advance for any replies.
 
feed the references into a link i.e.

Code:
<a href="script.php?refs=<?=$row['references']?>>Cross-Ref</a>

then in your receiving script break apart the references at the semicolon

Code:
$array1 = explode(";",$_GET['references']);

this will leave you with an array of references
if you need to clean up the references then here's the place to do it. i.e. trim?

Code:
foreach ($array1 as $key=>$val)
{
 $key = "'".mysql_escape_string(trim($val))."'"; //escapes and trims and adds quotes in one
}

you now have a usable array. now you need to turn it in to a where clause
Code:
$where = "where reference= " . implode(" OR reference = ", $array1);

echo $where; //for debug

and that should be that...
 
jpadie, thank you for the reply. Is there any limitation on the number or volume of data sent via the link? Some of the values passed would have 50 or more alpha-numeric values. Is there a limitation of any kind I will need to deal with on this issue?
 
there is a limitation but it runs to 2000 characters for modern browsers (it is the restriction on the max length of the url and the query string).

if you have problems with this then you could populate a form field with the data and then transfer that using the POST message.
 
The limitation on the number of characters available to a GET-method data-post is more a function of the web server's OS than anything. GET-method data is made available to a web script through an environment variable, the maximum lengths of which are OS-specific.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thanks for the clarification sleipnir214.

in this case the OP was not using a form to submit but creating a series of pre-built anchor links with query strings appended.

would this be subject to the browser limitations that i was concerned about or would the browser send the query string as an environment variable even though it was submitted outside a form?
 
It all boils down to the submission method. When data is sent on the URL (GET-method), the web server makes the data available to the script in an environment variable. This is defined in either the HTTP spec or the CGI spec, and the browser has no say in the matter.

The web server makes POST-method input available to a script via STDIN, so there's more input available.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank you for the replies. I am trying to understand and decipher what you are all saying. To try and help me grasp what you are saying, I have two follow-up questions:

Currently I get input from the user through drop down boxes, from a hyperlink appearing in the MySql database displayed by on a php results page, or from a free form search request. In the php results page the following hyperlink finds records matching Cats 122:111

<a href="../MD/ReferencePage.php?SeeAlso=Cats 122:111">Search</a>

More specifically, if the user clicks on a hyperlink embedded in the MySql database appearing on the php results page, the user would then pull up the Cats 122:111 record.

To get the above html hyperlink to appear in the MySql database I currently embed the above hyperlink code in the csv file and then upload the csv file.

FIRST QUESTION

In my application, the user does an initial search. After the initial search the user then see's alpha-numerica data in the References field the user will want to use in a further search. To use your suggestions about using an array, what would the hyperlink look like in the csv file before I upload the csv file if I wanted the user to click on a link containing the following four alpha-numeric pieces of data?

cat 122:111 ; dog 1000:222 ; foster 1111; tween 1:001

SECOND QUESTION:

Currently, the php page called in the above html hyperlink receives the hyperlink directly using the $SeeAlso variable. Below you will find the php code where the $SeeAlso variable is put into the $query.

Using your array suggestion, how would the following code need to be changed so the user could pull up four or more records like the sample records above?


$username = "aaaa";
$password = "aaaaa";
$dbname = "aaaa_table1";
$global_db = mysql_connect('localhost', $username, $password);
mysql_select_db($dbname, $global_db);

$query = "SELECT * FROM `ViewAAA` WHERE `Reference` REGEXP '[[:<:]]($SeeAlso)[[:>:]]'";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top