If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

search_result_template.php generates unique links, each in their own table cell, each with only these arguments:

?file=nnnnnn&descr=Namen (where "n" in lower case is a number)

So your download script as written works with the URL that's generated when a user clicks on any link.

Issue #2

If you want to pass multiple instances in a URL, here are 3 ways of many more possibilities to do it:

1) Just add an integer on the end of the argument name

?filen=nnnnnn&descrn=Namen&filen=nnnnnn&descrn=Namen...

2) Use a separator character such as | (pipe) or something between the values using only two arguments:

?file=nnnnnn|nnnnnn...&descr=Namen|Namen...

3) Create an array for files and description, serialize it and pass it to the URL (you could even use JSON for this):

?file=hash&descr=hash (where hash is a serialized array)

Then in download.php, depending on which method you choose above, parse the URL accordingly to extract the files and descriptions.

Hope this gets you thinking about some cool possibilities and on the right track to coding a cool solution. Others might chime in with more methods or code as they see fit, of course. These are just suggestions based on what I think you're trying to do.

Knowing your code doesn't generate that, it must be pointed out the example URLs you've posted is not advised. You seem to be using a space as a separator. But in the description what if a space exists already?

Pretending you adjusted the first script to generate an actual URL using a space as a deliminator between each file ID and description as you insist, download.php could be coded similar to this:

One approach of many you could take, highly simplified for proof of concept only. Just use the PHP explode command to get each file and description in its own array so you can loop through them to display, do whatever you want. Remember what I said though about the space. That's why I suggested the 3 alternatives above, no worries like that.

"Pretending you adjusted the first script to generate an actual URL using a space as a deliminator between each file ID and description as you insist" I did't insist, I don't know how to make in other way...

If you want to search for all files with the phrase you specified in the description, based on the code and information you've provided so far, you could modify the query like this:

select * from vslinks where caption like "&#37;Hamburg Music Concert%"

The above example assumes you have a search tool or some device where the user can specify what criteria to search for. I don't know your database structure other than in the code you provided so adjust the query field name to suit your needs as necessary (i.e. "caption"). All I did was use the MySQL "like" command which searches for any instance in the specified field of the chars between the %% delimiters unlike the use of "where" which is used for an exact match as you did correctly for the ID search in your original query.

Have fun!

-jim

Last edited by SrWebDeveloper; 02-17-2010 at 12:48 PM.
Reason: clarification

The query I gave you (aside from field name changes as I noted) using the like command in MySQL will do that if more than one row exists. I looked at your code which loops through the result set in reply #7 and it will return more than one row from what I can tell.

Did you try my code and make adjustments?

Post the new code showing the query and also post the relevant code that loops through the result set and echos. From what I can tell, your questions was asked and answered, but there may be a language barrier going on here. Thanks for your effort so far.

-jim

Last edited by SrWebDeveloper; 02-17-2010 at 01:58 PM.
Reason: confusion

My database table "v2links" database colums "id, url, caption"
"url is the link like http://www.site.com/page.php" and "caption is the title like Bob Dylan"

I already try this:

Code:

<?
include 'config.php';
$id = $_GET['file'];
mysql_connect(localhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die( "Unable to select database");
$query="SELECT * from v2links WHERE caption like "&#37;id%"
$result=mysql_query($query);
//get the number of rows in your array for loop
$num=mysql_numrows($result);
mysql_close();
//Here's the loop that uses $num from above as a boundary. The loop will seperate each data into a unique variable then echos out each however you like before it loops back.
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$caption=mysql_result($result,$i,"caption");
$url=mysql_result($result,$i,"url");
echo "$id - $caption - $url";
$i++;
}
?>

But give me an error
Parse error: syntax error, unexpected T_STRING in /home/site/public_html/site.com/download.php on line 142

That will fix the error and pass the proper variable. You inserted "id" not the variable named $id and you included a double quote without escaping it (I opted to wrap %$id% with a single quote).

Now, listen carefully, about this ID thing...

In your code $id is populated from $_GET['file'] which is populated by whatever the argument named "file" is in the URL for that page. You asked how to find all rows based on partial matches of the caption. If the "file" argument is indeed the caption text the user is searching for, fine. But I strongly suspect file contains the ID based on your code and what you wrote all along. If that is true, refer back to when I said "The above example assumes you have a search tool or some device where the user can specify what criteria to search for." I was referring to the caption, i.e. where does "Hamburg Music Concert" search criteria come from? If the query returns the wrong data, now you know why - in advance.

On a side note, once you knock this out, follow Mindzai's excellent advice and learn more about PHP/MySQL SQL injection security protection - your script is very vulnerable. This you can do on your own, view tutorial here.

-jim

Last edited by SrWebDeveloper; 02-17-2010 at 06:35 PM.
Reason: found a nice tutorial about sql injection so added that in